Difference between Matlab and Octave in random seeding

pbellec pbellec at bic.mni.mcgill.ca
Fri Mar 7 17:04:45 CST 2008


My understanding is that any difference of behavior between matlab and octave
should be regarded as a bug, so there should be different seeds for rand and
randn.

However, I must confess I have a very hard time with the use of different
seeds in matlab. I was not aware of this subtility when I started to perform
Monte Carlo simulations that mixed rand and randn calls, so I seeded rand
only. Because the Monte Carlo chain actually depend on both seeds, it took
me weeks before I finally found the bug. 

Suggestion of workaround : 
make Octave behave as Matlab, with specific seeds for rand and randn (and
rande and randg...), but create an octave-specific instruction
rand('all_state',S) which would seed all RNGs (rand, randn, rande, randg).
Adding this instruction in the help of rand* would force users to be aware
of the subtility.

Pierre


Michael Creel wrote:
> 
> The need for controlling how seeding is done is not different, nor is the
> need to be aware of the change. However, the change makes life more
> difficult and error-prone, I think, which is why I registered a vote
> against
> it.
> Cheers, Michael
> 
> On Fri, Mar 7, 2008 at 3:44 PM, Bateman David-ADB014 <
> David.Bateman at motorola.com> wrote:
> 
>>
>> The change that was made results in separate seeds for the rand, rand,
>> rande, randg and rande generators.. The other generators in the
>> statistics
>> toolbox rely on these five intrinsic generators and so will of cause now
>> be
>> seeded differently.
>>
>> However, I'm not sure I see the need for seeding in a parallel situation
>> being any different from the normal case. The programmer needs to be
>> aware
>> of the change in both cases.
>>
>> BTW, the old generators had/have seperate seeds, and the change makes the
>> behavior of seeding with 'state' or 'seed' similar.
>>
>>
>> -----Original Message-----
>> From: michael.creel at gmail.com on behalf of Michael Creel
>> Sent: Fri 07-Mar-08 9:27 AM
>> To: John W. Eaton
>> Cc: bug-octave at octave.org
>> Subject: Re: Difference between Matlab and Octave in random seeding
>>
>> On Thu, Mar 6, 2008 at 6:49 PM, John W. Eaton <jwe at bevo.che.wisc.edu>
>> wrote:
>>
>> > On  5-Mar-2008, Michael Creel wrote:
>> >
>> > | On this issue, I vote for having the seed set in a single spot for
>> all
>> > RNGs.
>> > | This facilitates greatly parallel use of Octave. Sometimes it's
>> > important to
>> > | be able to reset the seed, and it's a lot less likely to screw up if
>> > only
>> > | one needs to be reset.
>> >
>> > I guess I'm missing something because I don't see how having separate
>> > states for rand and randn has anything to do with parallelism.
>> >
>> > jwe
>>
>>
>> It doesn't have any intrinsic effect, of course, but from the point of
>> view
>> of ease of programming and likelihood of making hard to detect errors, it
>> is
>> not neutral. If RNG has its own seed, then the programmer must control
>> the
>> value of that seed on each node. If two RNGs that originally share a seed
>> become endowed with separate seeds in a new version of Octave, the
>> programmer must be aware of this. If he or she is not, the code will
>> continue to run, but with bogus results. If we're only talking about
>> having
>> one or two seeds for uniform and normal, it's not that big of a deal. But
>> if
>> RNGs for other distributions also go this route, it will be an
>> inconvenience. Basically, I find that the current situation with one seed
>> for all RNGs is ideal. Just my 2 euro cents.
>> Michael
>>
>>
> 
> _______________________________________________
> Bug-octave mailing list
> Bug-octave at octave.org
> https://www.cae.wisc.edu/mailman/listinfo/bug-octave
> 
> 

-- 
View this message in context: http://www.nabble.com/Difference-between-Matlab-and-Octave-in-random-seeding-tp15508096p15908425.html
Sent from the Octave - Bugs mailing list archive at Nabble.com.



More information about the Bug-octave mailing list