Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Multiple independent random number streams cannot be implemented.
Posted:
Mar 14, 2013 7:13 AM


Hopefully the title is enough of a red flag for someone to try to prove me wrong.
I want to implement two functions; lets call them f and g so that they both return random numbers. For example...
f[]:=RandomReal[]; g[]:=RandomReal[];
However I want f and g to return the same number when they're called for the nth time. So the first call to f is always the same number and the first call to g is always the same number.
In the above case (on my machine)... SeedRandom[1]; {f[], g[]} gives {0.168697, 0.113119}
and of course.. SeedRandom[1]; {g[], f[]} gives the same {0.817389, 0.11142}
Essentially I want f and g to to be independent random sources.
It is possible to localize the random number generators using BlockRandom but I do not see how that helps me in this case. BlockRandom localizes the state of the random number generators within the block where as I want to localize them into the symbol names.
Roger



