Cross-platform cross-language cross-everything actually deterministic random number generator

北城余情 提交于 2019-12-23 20:00:24

问题


I'm looking for an algorithm to generate random numbers from a given seed but with the particular requirement that it will always generate the same sequence of number regardless of the underlying computer architecture or language implementation.

I already know of Mersenne Twister, however, the numbers it generates differ when using different implementations (i.e. C MT vs Javascript MT).

Do algorithms with this property exist? Also, I don't need a state-of-the-art RNG, I don't even need it to be cryptographically secure, I just want to drive a "random" simulation on one place and have it follow the same behavior on a different implementation.


回答1:


If you don't need a cryptographicly secure RNG then MT or LCG would do. Still, some stream ciphers are pretty easy to implement in many languages, or already available, so these are viable paths. All of these are deterministic, same seed results in the same random numbers, and quite fast.



来源:https://stackoverflow.com/questions/27641246/cross-platform-cross-language-cross-everything-actually-deterministic-random-num

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!