Ran013: congruential combined. Returns integer random numbers uniformly distributed within [0,4294967295] (that means [0,2^32-1]. The period is about 2^125 > 4.25*10^37.
- At least 32 bit long int is required, but works with any larger
word lengths
- Reference:
This is algorithm "mzran13" from
G. Marsaglia and A. Zaman,
"Some portable very-long-period random number generators",
Computers in Physics, Vol. 8, No. 1, Jan/Feb 1994.
In the original implementation the algorithm relies on 32-bit
arithmetics with implicit modulo 2^32 on overflow. Since the
the size of unsigned longs may not always be 32 bit the
modulo 2^32 is coded explicitly using masks.
The performance loss is not very important.
The original code reads:
long s;
if (y > x+c) {
s = y - (x+c); c = 0;
} else {
s = y - (x+c) - 18; c = 1;
}
x = y;
y = z;
return ((z = s) + (n - 69069 * n + 1013904243));
^
Here it contains a misprint
Should really be a "=" !
| Constructor | Description |
Full Usage:
Ran013()
|
|
Full Usage:
Ran013(the_seed)
Parameters:
uint32
|
|
| Instance member | Description |
Full Usage:
this.Long
Returns: uint32
Modifiers: abstract |
|