CRPropa / CRPropa3

CRPropa is a public astrophysical simulation framework for propagating extraterrestrial ultra-high energy particles. https://crpropa.github.io/CRPropa3/
https://crpropa.desy.de
GNU General Public License v3.0
71 stars 69 forks source link

Update Random Number Generator to 64 Bit #21

Closed TobiasWinchen closed 9 years ago

TobiasWinchen commented 9 years ago

Our random number generator is absed on 32Bit random numbers. 64Bit may sometimes be needed, e.g. for the random distribution in healpix pixels. The current 64Bit Random capability is a hack that use 32Bit seed for a XORSHIFT algorithm which might be very predictable.

We should probably update to a 64Bit Mersenne Twister.

geromueller commented 9 years ago

The period of MT is 2^19937 − 1. It is predictable in terms of cryptography, read ~600 values and know all following. But it does not produce repeating sequences. The default Random::rand() returns a double, which does not use the full fraction resolution. e.g. only 2^32 different values. If you need full fraction resolution, use rand53().

There should be no problem with your code. An update to 64bit also has performance impacts. If someone has the time, we should look at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/

Gero

Am Mittwoch, 18. Februar 2015, 02:02:57 schrieb Tobias Winchen:

Our random number generator is absed on 32Bit random numbers. 64Bit may sometimes be needed, e.g. for the random distribution in healpix pixels. The current 64Bit Random capability is a hack that use 32Bit seed for a XORSHIFT algorithm which might be very predictable.

We should probably update to a 64Bit Mersenne Twister.


Reply to this email directly or view it on GitHub: https://github.com/CRPropa/CRPropa3/issues/21

Dipl.-Phys. Gero Müller III. Physikalisches Institut A RWTH Aachen University +49 (0)241 80 23567