[Top][All Lists]

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

Re: Re rand('state',0)

From: David Bateman
Subject: Re: Re rand('state',0)
Date: Fri, 14 Oct 2005 10:13:11 +0200
User-agent: Mozilla Thunderbird 0.8 (X11/20040923)

John W. Eaton wrote:

On 13-Oct-2005, David Bateman wrote:

| Do you have octave-forge installed? If not the rand/randn generators in | octave itself are signifiantly slower and don't support the 'state' | argument. So I'd suggest you install octave-forge even if you disable | this line..

2.9.x accepts both "state" and "seed".  But it is still the older rand
based on the Fortran ranlib.  Should we replace that with the code
from Octave-forge?


This question has come up before with no conclusion. If we introduce a new generator then we change the random sequences and some code that relies on the particular sequence of random values might break. The way matlab treated this is that is you used rand('seed',val) then the old generators were used and so those people who wanted a particular sequence forced the seed and got the old generator being used 'state' was reserved for the new generator.

The other issue was, should we try and duplicate the random sequence of matlab. Frankly I don't think that is possible, since we don't know how they hash the sequence or how they convert the 32-bit values from the MT to 53-bit values for the doubles. So regenerating their sequence without a code example will be difficult or impossible, and if we have an example code we break Mathwork's license... This is why a while back I took the alternative route of converting the octave-forge generator for use with matlab, by creating a mex-file interface to it.

My preference to treat this issue would be to integrate the MT into the existing liboctave octave_rand class and use the same trick as matlab to select the old sequence if 'seed' is defined. Forget about generating the exact same sequence as matlab. The question of what to do with rande and randp from octave-forge would then need to be considered. I'd suggest writing interfaces to ranlib sexpo and ignpoi for the exponential and poisson distributions with the old generators and include rande and randp in octave's octave_rand class. This would require a bit of reorganization of the octave-forge code but would be worth it in terms of backward compatibility...


David Bateman                                address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary

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]