numpy performance and random numbers

sturlamolden sturlamolden at yahoo.no
Sat Dec 19 09:16:16 EST 2009


On 19 Des, 14:06, Carl Johan Rehn <car... at gmail.com> wrote:

> Matlab and numpy have (by chance?) the exact names for the same
> functionality,

Common ancenstry, NumPy and Matlab borrowed the name from IDL.


LabView, Octave and SciLab uses the name randn as well.


> So the basioc question is, how can I speed up random number
> generation?

The obvious thing would be to compile ziggurat yourself, and turn on
optimization flags for your hardware.
http://www.jstatsoft.org/v05/i08/


P.S. Be careful if you consider using more than one processor.
Multithreading is a very difficult issue with PRNGs, becuase it is
difficult to guarrantee they are truely independent. But you can use a
producer-consumer pattern, though: one thread constantly producing
random numbers (writing into a buffer or pipe) and another thread(s)
consuming them.















More information about the Python-list mailing list