减法的滞后斐波那契不使用

减法的滞后斐波那契不使用

本文介绍了System.Random错误(减法的滞后斐波那契不使用(24,55)滞后)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET Reflector开启System.Random透露,它正在使用(34,55)而不是(24,55),用于减法滞后斐波那契生成器.这意味着其期限不能保证超过(2 ^ 55 -1).它引用了使用了(24,55)滞后的Knuth 1981. 您会在.NET Reflector解密代码中看到错误,该错误在公共Random(int Seed)的最后一部分中,其中设置了两个整数,即inext = 0和inextp = 21. inextp应该为31(= 55-24). 21).顺便说一下,该例程是数字食谱Ran3例程的逐字记录,因此很容易发现这种错字.

有没有人测试过这种错误"错误的随机性?发电机?例如,DieHard测试?即使有正确的延迟,Knuth版本也无法通过生日测试.我想知道错误"消息是否为错误"消息.生成器是否通过任何测试.

解决方案


.NET Reflector on  System.Random revealed that it is using (34, 55) ,not (24,55), for subtractive lagged Fibonacci generator.  This means that its period has no guarantee of longer than (2^55 -1).  It cites Knuth 1981 which uses (24, 55) lags.   You see the bug in .NET Reflector deciphered code in the last part of public Random(int Seed) where two integers are set, inext = 0 and inextp = 21.   inextp should be 31 (= 55 - 24).   Most likely this is the typo (31 became 21).   The routine by the way is a verbatim port of Numerical Recipes Ran3 routine and thus it is easy to spot this typo.   

Has anybody tested the randomness of this "wrong" generator?   For example, DieHard tests?   Even with the correct lags, Knuth version failed the birthday test.   I wonder whether the "wrong" generator passes any tests or not.

解决方案


这篇关于System.Random错误(减法的滞后斐波那契不使用(24,55)滞后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 14:27