[<<][compsci][>>][..]

Sat Feb 18 13:39:19 EST 2012

## Forking a random number generator?

For an animation framework I need random numbers in the "leaf nodes"
of an animation tree. However, I don't want to introduce a serial
dependency over the tree, i.e. through a state monad to track RNG
state.
Is it possible to "split" an RNG such that it has a tree-like (Reader
monad / S-combinator) dependency graph, while keeping the sequences
generated in the leaf nodes of this tree "random enough".
There is a random number generator that is seeded by integers:
mkStdGen :: Int -> StdGen
so maybe the question is: how to fork integers? Or, how to fork them
enough such that collisions are rare?
A very un-informed way would be to just multiply the seed by a prime
number. This will not reduce the configuration space and give a
reasonable "decorrelation" if the prime number is large enough?
The funny thing is that the decorrelation itself will be simpler to
express as a serial operation when forking a random number of states.
To parallellize this again a list of primes could be used..
Then when lists of primes arrive, it's probably also possible to just
use binary trees: shift by one and fork +0, +1 though that seems to
run out of states faster.

[Reply][About]

[<<][compsci][>>][..]