From: Peter Perkins <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: random numbers in parallel
Date: Fri, 26 Apr 2013 00:01:03 -0400
Organization: The MathWorks, Inc.
Lines: 11
Message-ID: <klcu5v$2d4$>
References: <>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: 1366948863 2468 (26 Apr 2013 04:01:03 GMT)
NNTP-Posting-Date: Fri, 26 Apr 2013 04:01:03 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
In-Reply-To: <>
Xref: comp.soft-sys.matlab:794383

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.