Wichmann-Hill

Wichmann-Hill is a pseudorandom number generator proposed in 1982 by Brian Wichmann and David Hill.[1] In its core, numbers are generated by taking the fractional part of a sum of rectangularly distributed numbers from imperfect algorithms. As the addition of fractional parts of numbers will be rectangularly distributed if only one of the number is rectangular, the method is an appropriate generator. In its crude form, three number generators are used to create a pseudorandom sequence with cycle exceeding .[2] A brute-force computation result of AS183[3] shows that the length of cycle is 6953607871644.

Implementation

The following pseudocode is for implementation on machines capable of integer arithmetic up to 30323.

[r, s1, s2, s3] = function(s1, s2, s3)
    % s1, s2, s3 should be random from 0 to 30,000. Use clock if available
    s1 = 171 * mod(s1, 177) - 2 * (s1/177)
    s2 = 172 * mod(s2, 176) - 35 * (s2/176)
    s3 = 170 * mod(s3, 178) - 63 * (s3/178)

    r = mod ( s1/30269 + s2/30307 + s3/30323 , 1)

On machines capable of integer arithmetic up to 5,212,632, the more compact version gives identical results

[r, s1, s2, s3] = function(s1, s2, s3)
    % s1, s2, s3 should be random from 0 to 30,000. Use clock if available
    s1 = mod ( 171 * s1, 30269 )
    s2 = mod ( 172 * s2, 30307 )
    s3 = mod ( 170 * s3, 30323 )

    r = mod ( s1/30269 + s2/30307 + s3/30323 , 1)

References

  1. Wichmann, Brian; Hill, David (1982). "Algorithm AS 183: An Efficient and Portable Pseudo-Random Number Generator". Journal of the Royal Statistical Society. Series C (Applied Statistics), Vol. 31, No. 2 (1982), pp. 188-190.
  2. Wichmann, Brian; Hill, David (1982). "Correction: Algorithm AS 183: An Efficient and Portable Pseudo-Random Number Generator". Journal of the Royal Statistical Society. Series C (Applied Statistics), Vol. 33, No. 1 (1984), p. 123.
  3. Rikitake, Kenji. "AS183 PRNG algorithm internal state calculator in C".
This article is issued from Wikipedia - version of the 1/12/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.