[SciPy-user] Generating and Sampling Random Numbers
Fri Oct 12 02:23:52 CDT 2007
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.
On 10/12/07, Anne Archibald <email@example.com> wrote:
> On 11/10/2007, Lorenzo Isella <firstname.lastname@example.org> 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.
> SciPy-user mailing list
More information about the SciPy-user