[SciPy-user] Generating and Sampling Random Numbers

Sebastian Haase haase@msg.ucsf....
Fri Oct 12 02:23:52 CDT 2007

Another comment:
Performance wise it will be much faster to generate a larger array of
rands in one go, rather than calling the python function at every
single time step.
Furthermore you might also want to perform as many time-steps in a
single python-call -- look at the cumsum function.

Compare the times - I guess I'm talking at least about a factor 10 in speed.

Sebastian Haase

On 10/12/07, Anne Archibald <peridot.faceted@gmail.com> wrote:
> On 11/10/2007, Lorenzo Isella <lorenzo.isella@gmail.com> wrote:
> > Here is my problem: in general I should not call e.g. stats.norm.rvs at
> > every time step, since it amounts to continually re-initializing the
> > random number generator, and any generator is guaranteed to have good
> > "randomness" only within a sequence. Instead frequent initializations,
> > i.e. many independent callings rather than generating a single long
> > sequence, may introduce some correlations in the sampled numbers.
> I think you're confused here. Unless I'm grievously mistaken, scipy's
> random number generator is initialized once the first time it is used,
> then all subsequent numbers are drawn from it. The normal use of
> scipy's random number generators is to call them and ask for however
> many random numbers you need; when you need more, call them again and
> more numbers will be generated from the sequence. The array-generation
> routines are a simple convenience.
> Anne
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

More information about the SciPy-user mailing list