本文介绍了可逆随机发生器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我想知道是否有一个可逆的随机发生器。我需要在我的应用程序中及时返回,并且仍然需要使用 确定性随机数。 RNG的大部分实现了Next函数 但是上一个怎么样? 我知道我可以使用数组来存储X的最后值但我是更多 有兴趣知道它是否存在允许倒退的东西。 此外,我真的不能使用相同的种子和循环直到我得到 之前的值。 谢谢! 解决方案 大多数PRNG都是有损的(就可逆性而言),依靠模数 操作来跳转数字空间。但是为什么你不能只将每个生成的数字推到堆栈上?然后,只要你需要及时回归,你就可以弹出并重新播种 。 - Richard Heathfield< http://www.cpax.org.uk> 电子邮件:-http:// www。 + rjh @ 谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php> Usenet是一个奇怪的放置" - dmr 1999年7月29日 这对于clc来说真的是OT,有点像comp.programming会更好,而且sci.crypt会很好,除了那个sci.scrypt在过去的几个月里已经完全是DOS了。 无论如何,这并不难,但是你做了需要决定你有多好,你想要伪造的随机数是多少。基本上使用一个计数器,然后 然后将它转换成一个随机数,并适当增加或 根据你的next_rand或prev_rand递减计数器 功能。如果您使用AES作为转换,那么在基本理解的CTR(计数器)模式下使用AES基本上就是,并且您将获得产生相当不错的随机数字。如果你想要一些相当简单(和更快)的东西,可以使用随机的东西。 的数量相当低质量,你可以做点反转的事情 计数器然后mod 32767它。 大多数PRNG都是有损的(就可逆性而言),依靠模数 操作来跳转数字空间。但是为什么你不能只将每个生成的数字推到堆栈上?然后,只要你需要及时回归,你就可以弹出并重新播种 。 - Richard Heathfield< http://www.cpax.org.uk> 电子邮件:-http:// www。 + rjh @ 谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php> Usenet是一个奇怪的放置" - dmr 1999年7月29日 问题是如果让我说我必须在 秒产生1000随机并需要存储100分钟随机,它不会真的是对记忆有益的。 Hi all,I was wondering if there is a random generator that is "reversible". Ineed to go back in time in my application and still need to usedeterministic random numbers. Most of RNG implement the Next functionbut what about a Prev ?I know I can use an array to store X last values but I''m moreinterested to know if it exist something that allows to go backwards.Also I can''t really afford to use the same seed and loop until i getthe previous value.Thank you ! 解决方案Most PRNGs are lossy (in terms of reversibility), relying on a modulooperation to jump around the number space. But why can''t you just pusheach generated number onto a stack? Then you can just pop and re-seedwhenever you need to go "back in time".--Richard Heathfield <http://www.cpax.org.uk>Email: -http://www. +rjh@Google users: <http://www.cpax.org.uk/prg/writings/googly.php>"Usenet is a strange place" - dmr 29 July 1999This is really OT for c.l.c, someplace like comp.programming would bebetter, and sci.crypt would be excellent, except that sci.scrypt hasbeen totally DOS''d for the past few months.Anyway, it''s not hard to do, but you do need to decide on how good youwant the psuedo random numbers to be. Basically use a counter, andthen transform it into a random number, and appropriate increment ordecrement the counter as appropriate for your next_rand or prev_randfunction. If you use AES as your transform, you''ll essentially beusing AES in the well understood CTR ("counter") mode, and you''llproduce pretty darn good "random" numbers. If you want somethingrather simpler (and faster), but can live with "random" numbers ofconsiderably lesser quality, you could do something like bit reversingthe counter and then "mod 32767" it.Most PRNGs are lossy (in terms of reversibility), relying on a modulooperation to jump around the number space. But why can''t you just pusheach generated number onto a stack? Then you can just pop and re-seedwhenever you need to go "back in time".--Richard Heathfield <http://www.cpax.org.uk>Email: -http://www. +rjh@Google users: <http://www.cpax.org.uk/prg/writings/googly.php>"Usenet is a strange place" - dmr 29 July 1999The problem is that if let''s say I have to generate 1000 random in asec and need to store 100 min of random, it''s not really going to begood for memory. 这篇关于可逆随机发生器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-21 12:31