[Numpy-discussion] Random number generation and testing across different OS's.

Robert Kern robert.kern at gmail.com
Fri Apr 12 10:57:37 EDT 2013


On Fri, Apr 12, 2013 at 8:20 PM, Andrew Nelson <andyfaff at gmail.com> wrote:
>     I have written a differential evolution optimiser that i use for
>     curvefitting.  As a genetic optimisation technique it is stochastic and
>     relies heavily on random number generators to do the minimisation.  As part
>     of the module tests I would like to write a cross-platform test that checks
>     if the fitting is being done correctly.
>     I use an instance of numpy.random.RandomState for the generation.  If I use
>     the seed method on a single platform I get the same output, which I could
>     use to write a test.  However, I am unsure of how the seeding and
>     RandomState works across platforms.
>     If I use the same seed on OSX/Windows/Linux, will I get the same stream of
>     random numbers being generated? I need to know if the test I write works
>     across platforms.

Modulo bugs, if you are using the same exact version of numpy on all
platforms, you should be getting the same output bytes from the same
seed. Some of the distributions may have some differences between
32-bit and 64-bit in some rare cases where a C long would overflow on
the 32-bit platform but won't on a 32-bit platform, but those are
usually indicative of bugs to be fixed.

--
Robert Kern



More information about the NumPy-Discussion mailing list