The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: random generator seed
Replies: 4   Last Post: Jan 25, 2013 5:41 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: random generator seed
Posted: Jan 25, 2013 5:27 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Elnaz " <> wrote in message
> Hi all,
> I am running several MATLAB in parallel and I want to have my script
> running on several machines generate the same random numbers. To do this,
> I am doing rng('default'); Is this the same as doing:
> rand('state',0); % set state to 0

No, and you probably shouldn't be doing the latter if you can avoid it.

> In other worsd, is the default setting '0'?

No. See the page linked in the Note at the top of the Description section
for a more thorough explanation of what rng('default') is doing and why we
discourage the rand(string, seedValue) and randn(string, seedValue)

That page also lists the RNG equivalent for "rand('state', 0)" if you need
to reproduce results from older releases of MATLAB.

Steve Lord
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.