help-octave
[Top][All Lists]
Advanced

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

## Re: same pseudo random sequence in matlab?

 From: Markus Bergholz Subject: Re: same pseudo random sequence in matlab? Date: Sat, 5 Jul 2014 06:10:55 +0200

On Fri, Jul 4, 2014 at 10:53 AM, Andreas Weber wrote:
Hi at all.

Is it possible to get the same pseudo random sequence in Octave and
Matlab?

Of course it is.

Use in Matlab

>> rand('twister',0)
>> rand

ans =

0.548813503927325

In Octave you need as workaround first a function to set the seed state
Then simple run

octave:1> rand('twister',twister_seed(0))
octave:2> rand
ans =    0.548813503927325

And default Matlab seed is
octave:3> rand('twister',twister_seed(5489))

With twister_seed() the result are equivalent to numpy and ruby too

I tried setting seed and state:

Octave 4.1.0+ 47d4b680d0e0
octave:1> rand('state', 1); rand(1,3)
ans =
0.13436   0.84743   0.76377
octave:2> rand('seed', 1); rand(1,3)
ans =
0.866802   0.912651   0.093661

Matlab R2014a:
>> rand('state', 1); rand(1,3)
ans =
0.9528    0.7041    0.9539

>> rand('seed', 1); rand(1,3)
ans =
0.5129    0.4605    0.3504

-- Andy

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave

--
icq: 167498924
XMPP|Jabber: address@hidden

reply via email to

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