Function rgsl::types::rng::other::ranf
[−]
[src]
pub fn ranf() -> RngType
This is the CRAY random number generator RANF. Its sequence is
x_{n+1} = (a x_n) mod m defined on 48-bit unsigned integers with a = 44485709377909 and m = 248. The seed specifies the lower 32 bits of the initial value, x_1, with the lowest bit set to prevent the seed taking an even value. The upper 16 bits of x_1 are set to 0. A consequence of this procedure is that the pairs of seeds 2 and 3, 4 and 5, etc. produce the same sequences.
The generator compatible with the CRAY MATHLIB routine RANF. It produces double precision floating point numbers which should be identical to those from the original RANF.
There is a subtlety in the implementation of the seeding. The initial state is reversed through one step, by multiplying by the modular inverse of a mod m. This is done for compatibility with the original CRAY implementation.
Note that you can only seed the generator with integers up to 232, while the original CRAY implementation uses non-portable wide integers which can cover all 248 states of the generator.
The function gsl_rng_get returns the upper 32 bits from each term of the sequence. The function gsl_rng_uniform uses the full 48 bits to return the double precision number x_n/m.
The period of this generator is 246.