[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rand('state',0)

From: Quentin Spencer
Subject: Re: rand('state',0)
Date: Thu, 13 Oct 2005 15:10:59 -0500
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929)

Steve C. Thompson wrote:

I'm collaborating with MATLAB users and they have
rand('state',0) in their code. According to <>
this is used in MATLAB to ``set rand to its default initial
state''.  This command produces an error in Octave, however:

 octave:1> rand('state',0)
 error: rand: unrecognized string argument

What version of octave are you using? I don't get this error with 2.9.3. I haven't tried 2.1.71.

Can someone tell me if by simply commenting out this line of
code will have any side effects?
The purpose of doing something like this is usually to make simulations involving random number generation repeatable. Removing this line will probably not break the code, but it could make it non-repeatable. Matlab and Octave don't have the same random number generator, so even with this line, you won't be able to duplicate exactly the random numbers generated in the two programs. If that's important, David Bateman posted some code to achieve that earlier this year, but it involves changing Matlab's random number generation.


Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]