I'm doing some simulations of the Langevin equation, for various external forces. Being told that C's rand() from stdlib.h can introduce bias in my results, I'm using a Mersenne Twister.
Nevertheless, I would like to know (and see) exactly what kind of errors a linear congruential generator can introduce in my simulation. These are things that I have tried:
- Generating 3D tuples of randoms to try to see hyperplanes. I can't see anything.
- Doing the FFT of a large vector of random numbers. It's almost the same for both the Mersenne Twister and
rand(). - Checking the equipartition principle for a particle in Brownian motion. Both integrators agree in the expected value of $\langle \text{KE}\rangle=\frac{1}{2}k_BT$ with the same number of significant digits.
- Seeing how well they bin in a number of bins that is not a power two. Both give the same qualitative results, no one being better.
- Looking at Brownian paths to see clear divergences from $\langle x\rangle = 0$. Again, no luck.
- Distribution of points in a circle. Filled, and only in the perimeter. Between all of them and between nearest neighbours (Shor's answer, below in the comments). Available in this gist, just run it with Julia 0.5.0 after installing the needed libraries (see the gist for instructions).
I would like to emphasize that I am looking for introduced bias in the context of physical simulations. For example, I have seen how rand() fails miserably the dieharder tests while the Mersenne Twister doesn't, but for the moment that doesn't mean too much for me.
Do you have any physical, concrete, examples on how a bad random number generator wrecks a Montecarlo simulation?
Note: I have seen how PRNG's like RANDU can be awful. I'm interested on not obvious examples, of generators that look innocent but ultimately introduce bias.
/dev/randomor /dev/urandom` on Linux or MacOS. If you're concerned about performance of PRNGs, this might be a better option. – Daniel Shapero Nov 02 '16 at 23:20