Marsaglia RNG in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg38958] Marsaglia RNG in Mathematica
- From: "flip" <flip_alpha at safebunch.com>
- Date: Wed, 22 Jan 2003 06:14:11 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hello All, I was wondering if someone here would be nice enough to convert this C to Mathematica code. A module would be best I suppose, so users can just call it just like Random[]. I'd like to experiment with this RNG in Mathematica. In fact, IIRC Mathematica uses some variant of SWC also. Thank you to anyone that can help. Flip (remove "_alpha" to email me directly) By the way, the following words are from another thread in another NG regarding a RNG. *** Words below from Dr. Marsaglia *** Here is a MWC example with period 3056868392^33216-1, a mere 10^4005 times as long as that of the Mersenne twister, yet faster, far simpler, and seemingly at least as well-performing in tests of randomness: static unsigned long Q[1038],c=362436; unsigned long MWC1038(void){ static unsigned long i=1037; unsigned long long t, a=611373678LL; t=a*Q[i]+c; c=(t>>32); if(--i) return(Q[i]=t); i=1037; return(Q[0]=t); } You need to assign random 32-bits seeds to the static array Q[1038] and to the initial carry c, with 0<=c<61137367. George Marsaglia
- Follow-Ups:
- Re: Marsaglia RNG in Mathematica
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Marsaglia RNG in Mathematica