6

请参阅http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#setSeed(long)。在将乘数减少到 mod 2^48 之前,代码 xor 种子与乘数。为什么不直接减少传递的种子 mod 2^48?C 等效的 seed48 不执行异或。

4

1 回答 1

3

您可以在这里找到一本不错的读物:java.util.Random's Magic Number 0x5DEECE66D

和报价:

The analysis says it was chosen simply because researchers determined empirically 
that it produces a sequence of values satisfying various randomness tests

这份文件也给出了幻数的机会。

还有一个报价:

然后我尝试搜索十进制值,不包括 Java,并在一些课堂笔记中找到了答案:

http://nut.bu.edu/~youssef/py502/monte_carlo_supplement.ps http://www.inf.ethz.ch/personal/gaertner/texts/own_work/random_matrices.pdf

and in some computer documentation:

http://developer.apple.com/documentation/Darwin/Reference/ManPages/html/_rand48.3.html

The Youssef notes say:

... I can only say that 25214903917_LONG and 11_LONG have
apparently been chosen by passing a battery of such [meaning
Marsaglia's DIEHARD] tests.

... Even in the case of the 48-bit generators we are discussing
today, cas26 will generate them all in a month or two of CPU time
and then start to repeat.
于 2013-01-10T17:59:52.323 回答