[SciPy-user] Generating and Sampling Random Numbers
Thu Oct 11 16:38:24 CDT 2007
I will probably soon have to deal with the following problem.
Think about a 2D box (a simple rectangle) containing a particle
(actually many particles) undergoing Brownian motion (or some stochastic
process in general) in the box.
Simulating its dynamics requires an integration scheme which in turn
relies on sampling a random normally-distributed variable at every time
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.
However, it is rather cumbersome to do something like:
and then read a number from the my_random array at every time step while
also keeping track of the position of the last read number on the array.
Is there any better way of doing this?
More information about the SciPy-user