mwc-random
mwc-random copied to clipboard
simpler version of MWC256?
I found a different (simpler) version of MWC256 that George Marsaglia himself posted on the internet. It has the same 2^8222 period and Marsaglia vetted the quality of the PRNG as well. The version that we currently use comes from Feb 25, 2003 https://groups.google.com/d/msg/sci.math/k3kVM8KwR-s/jxPdZl8XWZkJ:
static unsigned long Q[256],c=362436;
unsigned long MWC256(void){
unsigned long long t,a=1540315826LL;
unsigned long x;
static unsigned char i=255;
t=a*Q[++i]+c; c=(t>>32);
x=t+c; if(x<c){x++;c++;}
return(Q[i]=x); }
Another version comes from May 13, 2003 https://groups.google.com/d/msg/comp.lang.c/qZFQgKRCQGg/rmPkaRHqxOMJ:
static unsigned long Q[256],c=362436; /* choose random initial c<809430660 and */
/* 256 random 32-bit integers for Q[] */
unsigned long MWC256(void){
unsigned long long t,a=809430660LL;
static unsigned char i=255;
t=a*Q[++i]+c; c=(t>>32);
return(Q[i]=t); }
Why was the first version chosen for mwc-random?