8 ms·
How is "stream" not just half of the seed? This is a property of every PRNG with large enough seed.
by gliptic 5y ago
How is "stream" not just half of the seed? This is a property of every PRNG with large enough seed.
- jsheard 5y agoThe difference is when you're using many PRNG instances in parallel for SIMD, or threaded, or distributed applications, randomly seeded PRNGs might land close to each other in the sequence and end up correlated with each other, but if you ensure each one has a unique stream that's guaranteed not to happen.
- searealist 5y agoThe choice is not "randomly seeded" vs "streams". If you have a 64 bit seed + 64 bit stream, then it's trivially the same as a 128 bit seed. Just use the top 64 bits of the 128 bit seed as the "stream id".
- jsheard 5y agoPartitioning the seed into "seed + ID" only protects you from using the exact same seed for multiple generators, those unique seeds can still begin close to each other in the sequence and overlap their outputs as they step through it. With proper streams every generator has a different sequence so no matter how the seeds are generated, or even if the seeds are the same, they won't overlap each other at any point. For a game it probably doesn't matter, but for more statistically demanding applications it's a nice property to have.
- CGamesPlay 5y agoI'm very confused by what you're saying. It seems you're saying that knowing the state of stream 1 teaches me some information about stream 2, specifically that it's guaranteed not to overlap outputs to the first stream. Why is that desirable?
- searealist 5y agoYeah, I guess you really just need a jump function and then streams are just partitioning the space by whatever distance.
- attractivechaos 5y agoYes, it works, if you can jump 2^64 iterations quickly. This is how xoroshiro achieves multiple streams. The PCG32 or the xoroshiro method guarantees independent streams. Using high bits in seeds doesn't have the guaranteed behavior. When you have many streams, stream collisions may become an issue.
- fpgaminer 5y agoRight? I'd also be concerned about hash collisions causing one to accidentally generate the same level twice. Seems better to use something like ChaCha; plenty fast and a much large seed space.
- irskep 5y agoHi, I wrote this post and I've come to agree with you. That's all. :-)