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

fred fredmfp@gmail....
Wed Aug 22 10:49:04 CDT 2007

Emanuele Zattin a écrit :
> mmm... what about something like:
> random.shuffle(A.ravel())
Hi all,

I would like to show how I use this,
with a result, which seems to be strange to me.

I have a float array, with dimensions of 501x501.
The values in this array are the scalar values at the point (x=i*dx, 
with i=0..500 & j=0..500.

I flatten this array and get 15000 random (with random.permuation 
method) values from this array
and thus get 15000 points.
Then I want to find out the number of neighboors from each of theses points,
in a neighboorhood of (2*20+1)x(2*20+1).

Thus, I get an array with coords and the number of neighboors.
x0 y0 nb0
x1 y1 nb1

I display the result with mayavi2, and get the following snapshot:

Structures clearly appear.
(I don't consider side effects, of course).

What could be the meaning of this ?
If it was "totally random", should I not get no structure at all, 
something like a white noise ?

What am I doing wrong ?

How can I get a totally random scatter points ?




More information about the SciPy-user mailing list