No subject


Thu Nov 16 16:52:29 CST 2006


(pseudo)random number generator with that many samples. These have a
tendency to repeat so your random number stream is no longer random.
See the Wikipedia entry:
http://en.wikipedia.org/wiki/Pseudorandom_number_generator

If I recall correctly, the Python random number generator is a
Mersenne twister but ranlib  is not and so prone to the mentioned
problems. I do not know if SciPy adds any other generators.

Finally I would also cheat by reducing the stdev values because in
many cases you will not see a real difference between a normal with
mean zero and variance 1.0 and a normal with mean zero and variance
1.1 (especially if you are doing more than comparing distributions so
there are more sources of 'error') unless you have a really large
number of samples.


Regards
Bruce

On 4/5/06, Eric Emsellem <emsellem at obs.univ-lyon1.fr> wrote:
> Hi,
>
> I am trying to optimize a code where I derive random numbers many times
> and having an array of values for the stdev parameter.
>
> I wish to have an efficient way of doing something like:
> ##################
> stdev =3D array([1.1,1.2,1.0,2.2])
> result =3D numpy.zeros(stdev.shape, Float)
> for i in range(len(stdev)) :
>    result[i] =3D numpy.random.normal(0, stdev[i])
> ##################
>
> In my case,  stdev can in fact be an array of a few millions floats...
> so I really need to optimize things.
>
> Any hint on how to code this efficiently ?
>
> And in general, where could I find tips for optimizing a code where I
> unfortunately have too many loops such as "for i in range(Nbody) : "
> with Nbody being > 10^6 ?
>
> thanks!
> Eric
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting langua=
ge
> that extends applications into web and mobile media. Attend the live webc=
ast
> and join the prime developer group breaking into this new coding territor=
y!
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>




More information about the Numpy-discussion mailing list