Re: pseudo-random generator -- save state
From: Unruh (unruh-spam_at_physics.ubc.ca)
Date: 11/14/05
- Previous message: Cristiano: "Re: pseudo-random generator -- save state"
- In reply to: Cristiano: "Re: pseudo-random generator -- save state"
- Next in thread: Cristiano: "Re: pseudo-random generator -- save state"
- Reply: Cristiano: "Re: pseudo-random generator -- save state"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 14 Nov 2005 22:43:02 GMT
"Cristiano" <cristiano.pi@NSquipo.it> writes:
>George Marsaglia wrote:
>> The following C program generates the base-b 'digits"
>> of 1/p for the prime p=18782*2^131072+1 in reverse order,
>> with b=2^32-1.
>>
>> static unsigned long Q[4096],c=362436;
>>
>> unsigned long CMWC4096(void){
>> unsigned long long t, a=18782LL,b=4294967295LL;
>> static unsigned long i=4095;
>> unsigned long x,r=b-1;
>> i=(i+1)&4095;
>> t=a*Q[i]+c;
>> c=(t>>32); t=(t&b)+c; if(t>r) {c++; t=t-b;}
>> return(Q[i]=r-t); }
>>
>[...]
>> Fast and simple, it seems to pass tests of
>> randomness very well.
>Yes, but I would say that some kind of initialization (of the Q[] vector)
>should be avoided.
Here you say it should be avoided and then you say it should be done with a
PRNG. But that would not give the digits of 1/p In fact that program seems
to be pretty weird. For the first 4096 "digits" all you get are basically
the initial values of Q[i]
>For example, Q[i]= i * K, for any K gives bad results. Also Q[i]= (i * K) +
>... + (i * K) is bad.
>I would suggest to use at least a PRNG (even an LCG) to initialize the Q[]
>vector. In that case, your generator seems very good, it never fails the
>tests.
And that is probably a statement about your initial initialisation of Q,
rather than about this generator.
And what tests?
Note that this is not a cryptographically strong.
Again, what does the OP want these for.
- Previous message: Cristiano: "Re: pseudo-random generator -- save state"
- In reply to: Cristiano: "Re: pseudo-random generator -- save state"
- Next in thread: Cristiano: "Re: pseudo-random generator -- save state"
- Reply: Cristiano: "Re: pseudo-random generator -- save state"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|