[Numpy-discussion] selecting random array element

Alan G Isaac aisaac at american.edu
Mon Feb 20 11:44:02 CST 2006

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)

Note the note.  ;-)

Alan Isaac

More information about the Numpy-discussion mailing list