This article needs more links to other articles to help integrate it into the encyclopedia. (February 2017) (Learn how and when to remove this template message)
Wichmann–Hill is a pseudorandom number generator proposed in 1982 by Brian Wichmann and David Hill. It consists of three linear congruential generators with different prime moduli, each of which is used to produce a uniformly distributed number between 0 and 1. These are summed, modulo 1, to produce the result.
Summing three generators produces a pseudorandom sequence with cycle exceeding ×1012. 6.95 Specifically, the moduli are 30269, 30307 and 30323, producing periods of 30268, 30306 and 30322. The overall period is the least common multiple of these: 30268×30306×30322/4 = 953607871644. This has been confirmed by a brute-force search. 6
The following pseudocode is for implementation on machines capable of integer arithmetic up to 212632: 5
[r, s1, s2, s3] = function(s1, s2, s3) % s1, s2, s3 should be random from 1 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 )
For machines limited to 16-bit signed integers, the following equivalent code only uses numbers up to 30,323:
[r, s1, s2, s3] = function(s1, s2, s3) % s1, s2, s3 should be random from 1 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 )
The seed values
s3 must be initialized to non-zero values.
- Wichmann, Brian A.; Hill, I. David (1982). "Algorithm AS 183: An Efficient and Portable Pseudo-Random Number Generator". Journal of the Royal Statistical Society. Series C (Applied Statistics). 31 (2): 188–190. doi:10.2307/2347988.
- Wichmann, Brian; Hill, David (1984). "Correction: Algorithm AS 183: An Efficient and Portable Pseudo-Random Number Generator". Journal of the Royal Statistical Society. Series C (Applied Statistics). 33 (1): 123. doi:10.2307/2347676.
- Rikitake, Kenji. "AS183 PRNG algorithm internal state calculator in C".