非递归随机数生成器 [英] Non-recursive random number generator

查看:99
本文介绍了非递归随机数生成器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了伪RNG算法,但是我所能找到的似乎都是通过使用前一个结果作为种子来生成下一个数字的.有没有一种非递归的生成它们的方法?

I have searched for pseudo-RNG algorithms but all I can find seem to generate the next number by using the previous result as seed. Is there a way to generate them non-recursively?

我需要的场景是在OpenCL并发编程期间,每个线程/像素需要一个独立的RNG.我尝试使用BIG_NUMBER + work_id为它们播种,但是结果中具有很强的视觉模式.我尝试了几种不同的RNG算法,但都遇到了这个问题.显然,它们仅在递归生成时才保证数字是独立的,而在使用顺序数字作为种子时则不能保证.

The scenario where I need this is during OpenCL concurrent programming, each thread/pixel needs an independent RNG. I tried to seed them using BIG_NUMBER + work_id, but the result has a strong visual pattern in it. I tried several different RNG algorithms and all have this problem. Apparently they only guarantee the numbers are independent if you generate recursively, but not when you use sequential numbers as seed.

所以我的问题是:我可以从序列号数组中为每个数字独立且恒定的时间生成一个随机数数组吗?还是数学上不可能?

作为我的openCL问题的解决方案,我可以先递归地预先生成大量随机数,然后将其存储在GPU内存中,然后再使用种子作为索引来使用它们.但是我对上面的问题很好奇,因为根据我对混沌理论的简单理解,仅仅通过一堆溢出和截止似乎很有可能.

As the solution to my openCL problem, I can just pre-generate a huge array of random numbers recursively first and store in GPU memory, then use them later using seed as index. But I'm curious about the question above, because it seems very possible just by doing bunch of overflow and cutoffs, according to my very simple understanding of chaos theory.

推荐答案

我可以从序列号数组中为每个数字独立且恒定的时间生成一个随机数数组吗?还是数学上不可能?

Can I generate an array of random numbers, from an array of sequential numbers, independently and constant time for each number? Or is it mathematically impossible?

确定可以-在计数模式下使用分组密码.通常称为基于计数器的RNG ,首先广泛使用的是 Fortuna RNG

Sure you can - use block cipher in countnig mode. It is generally known as Counter based RNG, first widely used one was Fortuna RNG

这篇关于非递归随机数生成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆