|
From: Robert K. <rob...@gm...> - 2006-02-20 22:41:49
|
Alan G Isaac wrote: > At http://www.american.edu/econ/pytrix/pytrix.py find > def permute(x): > '''Return a permutation of a sequence or array. > > :note: Also consider numpy.random.shuffle > (to permute *inplace* 1-d arrays) > ''' > x = numpy.asarray(x) > xshape = x.shape > pidx = numpy.random.random(x.size).argsort() > return x.flat[pidx].reshape(xshape) You may want to consider numpy.random.permutation() In [22]: numpy.random.permutation? Type: builtin_function_or_method Base Class: <type 'builtin_function_or_method'> String Form: <built-in method permutation of mtrand.RandomState object at 0x3f0f0> Namespace: Interactive Docstring: Given an integer, return a shuffled sequence of integers >= 0 and < x; given a sequence, return a shuffled array copy. permutation(x) -- Robert Kern rob...@gm... "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter |