Path: news.mathworks.com!not-for-mail
From: Peter Perkins <Peter.Remove.Perkins.This@mathworks.com>
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$1@newscl01ah.mathworks.com>
References: <74bbfeaa-2bc7-4c3d-9b2c-39624a0229bb@googlegroups.com>
NNTP-Posting-Host: ah-pperkins.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: newscl01ah.mathworks.com 1366948863 2468 172.28.17.104 (26 Apr 2013 04:01:03 GMT)
X-Complaints-To: news@mathworks.com
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: <74bbfeaa-2bc7-4c3d-9b2c-39624a0229bb@googlegroups.com>
Xref: news.mathworks.com 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.