两个 PRNG 可以用不同的种子产生相同的数字吗?

问题描述:

我知道如果您将相同的种子与两个不同的 PRNG 一起使用,您将收到相同的数字序列.有谁知道是否可以用两个不同的种子生成相同的数字?如果是这样,几率是多少?

I know if you use the same seed with two different PRNG's you'll receive the same sequence of numbers. Does anyone know if it's possible to generate the same number with two different seeds? If so, what are the odds?

我对此进行了测试并收到了一些奇怪的结果.如果我有两个相同 PRNG 的实例,并且每次都用两个不同的随机种子播种.随机数必须介于 0 和 1000 之间.经过 10,000,000 次迭代后,我得到了 1046 次相同的数字.如果我没有在每次收到大约相同数量的相同数量(1033)时播种它们.我不明白什么?我认为如果你不是每次都重新播种(嗯,也许不是),几率会更大.就像从两副牌中挑选两张牌一样.如果我每次都不洗牌,我会认为如果我洗牌,赔率会有所不同.

I ran a test on this and received some strange results. If I have two instances of the same PRNG and I seed them with two different random seeds each time. The random number has to be between 0 and 1000. I get the same number 1046 times after 10,000,000 iterations. If I don't seed them each time I receive about the same number about the same number of times (1033). What am I not understanding? I would think the odds would be much greater if you don't re-seed each time (hmm, maybe not). Much like picking two cards from two decks. If I don't shuffle the cards each time I would think the odds would be different then if I do.

谢谢,加里

几率取决于您使用的 PRNG.假设它生成均匀分布的数字并且您的种子是随机选择的*,那么它只是您可以表示的不同数字数量的函数.

The odds depend on the PRNG you're using. Assuming it generates numbers in an even distribution and your seed is chosen randomly* then it's just a function of the number of different numbers you can represent.

*Random 意味着与之前的种子没有关系,也不知道所使用的算法.

*Random means with no relation to the previous seed, and no knowledge of the algorithm being used.

对于 32 位整数,您可以表示 2^32 个不同的数字,因此给定一个整数,另一个足够随机数相同的几率是 1/(2^32).

For a 32 bit integer you have 2^32 different numbers you can represent, so given one integer, the odds of another sufficiently-random number being the same is 1/(2^32).