[SciPy-user] choose at random all elements in a array...

David Cournapeau david@ar.media.kyoto-u.ac...
Sat Aug 4 05:05:17 CDT 2007


fred wrote:
> Hi,
>
> Say I have an array with 250 000 values.
>
> I want to choose at random _all_ the elements of this array,
> _once and only once_.
>
> How can I do this ?
>
> TIA.
>
> Cheers,
>
>   
You can simply use a random permutation:

import numpy
a = numpy.array([1, 2, 3, 4, 5, 6])
numpy.random.permutation(a)

David



More information about the SciPy-user mailing list