<< intprb_muvstepupdate Support Functions intprb_tuplenext >>

Intprbs >> Intprbs > Support Functions > intprb_shragerandom

intprb_shragerandom

A portable random number generator by Schrage.

Calling Sequence

[ value, seed ] = intprb_shragerandom ( seed )

Parameters

seed :

a 1-by-1 matrix of doubles, integer value, a seed for the random number generator. The seed must be a positive, nonzero floating point integer less than 2147483647.

value :

1-by-1 matrix of doubles, a pseudorandom value uniform in [0,1].

Description

This is a portable random number generator by Schrage. The generator is based on the multiplicative congruential generator

X = A * X (mod M)

with

A = 16807

and

M = 2^31 - 1 = 2147483647.

Schrage states that the generator is full cycle, with period M. The implementation may be slower than Park and Miller's "Good ones are hard to find". Genz uses the seed = 123456.

This function is used in Genz's problem, for the computation of the parameters of the function.

Examples

// A sequence of random numbers uniform in [0,1]
seed = 123456;
[ value, seed ] = intprb_shragerandom ( seed )
[ value, seed ] = intprb_shragerandom ( seed )
[ value, seed ] = intprb_shragerandom ( seed )

// Another sequence
seed = 1
for i = 1 : 1000
[ value, seed ] = intprb_shragerandom ( seed );
end
// Must be : seed = 522329230
mprintf("seed = %d",seed)

Authors

Bibliography

"A More Portable Fortran Random Number Generator", Linus Schrage, ACM Transactions on Mathematical Software, Volume 5, Number 2, June 1979, pages 132-138.

"A pseudo-random number generator for the system/360", Lewis, P A W, Goodman, A.S., And Miller, J M . IBM Syst. 3". 8, 2 (1969), 136-146.


Report an issue
<< intprb_muvstepupdate Support Functions intprb_tuplenext >>