|
Wichmann-Hill is a pseudorandom number generator proposed in 1982 by Brian Wichmann and David Hill. 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 . == Implementation == The following pseudocode is for implementation on machines capable of integer arithmetic up to 30323. (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 (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) 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Wichmann-Hill」の詳細全文を読む スポンサード リンク
|