help-octave
[Top][All Lists]
Advanced

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

Re: cellfun and parcellfun


From: David Bateman
Subject: Re: cellfun and parcellfun
Date: Mon, 14 Jun 2010 21:01:27 +0200
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706)

Robert Patterson wrote:
On Mon, 2010-06-14 at 19:16 +0200, David Bateman wrote:
Robert Patterson wrote:
On Fri, 2010-06-11 at 23:28 +0200, David Bateman wrote:
I think I am doing something pretty stupid in trying to reset my RNGs:

octave:187> rand("state", 123); rande()
ans =  0.042798
octave:188> rand("state", 123); rande()
ans =  0.49064
octave:189> rand("state", 123); rande()
ans =  4.2087

I was expecting to get the same value each time.  Is the hash used to
initialise the Mersenne Twister non-deterministic?

Thanks

Robert


The older randlib generators have the same base generator so the above will work if you replace "state" by "seed". However the cost of that will be speed and a short length of the pseudo random sequence...

The Mersenne Twister hash is deterministic but you have to initialize each generator separately

octave:1> rande("state",123); rande()
ans =  0.27640
octave:2> rande("state",123); rande()
ans =  0.27640
octave:3> rande("state",123); rande()
ans =  0.27640

D.


This gradually became clear from the source.  However, in
S 17.4 Special Utility Matrices the manual states:

The new random generators all use a common Mersenne Twister generator,
and so the state of only one of the generators needs to be reset. The
old generator function use separate generators.

If I understand correctly, the manual is wrong.

This was true, but since early 2008 with the changes made in the long discussion

http://octave.1599824.n4.nabble.com/Difference-between-Matlab-and-Octave-in-random-seeding-td1669992.html

the generator now have separate states. The randlib generators also have separate seeds, though I'd forgotten about that. Note that the change was also documented in 2008

http://octave.1599824.n4.nabble.com/manual-update-for-general-documentation-for-random-generators-td1671067.html

so I suspect the manual you are referring to is out of date

D.


reply via email to

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