|
From: Alan G I. <ai...@am...> - 2006-02-20 19:43:18
|
At http://www.american.edu/econ/pytrix/pytrix.py find def permute(x): =09'''Return a permutation of a sequence or array. =09:note: Also consider numpy.random.shuffle =09 (to permute *inplace* 1-d arrays) =09''' x =3D numpy.asarray(x) =09xshape =3D x.shape =09pidx =3D numpy.random.random(x.size).argsort() =09return x.flat[pidx].reshape(xshape) Note the note. ;-) Cheers, Alan Isaac |