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



Re: random numbers in parallel
Posted:
Apr 26, 2013 12:01 AM


On 4/25/2013 8:01 PM, Gideon wrote: > I was wondering if people knew how robust the standard matlab rng function was when used in parallel matlab. The problem I have in mind just has a parfor loop and I'm generating monte carlo samples. I know there are issues when using random numbers in parallel to ensure each thread is generating independent samples. How is this handled in MATLAB? If I generically set rng(SEED) at the beginning of my code, then go into the parallel section, calling randn, will that be sufficient, or do I need to do something more sophisticated?
Gideon, on parallel workers, the default generator is mrg32k3a, which is specifically designed for parallel simulation. Without knowing specifically what you are doing, it's hard to say exactly what initialization you might need to do, but it may be that you don't need to do anything at all  the workers are automatically set up with parallel independent streams, and in many cases that's all you need.
Hope this helps.



