help-octave
[Top][All Lists]
Advanced

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

Re: Same sequence of random number generators than under Matlab?


From: David Bateman
Subject: Re: Same sequence of random number generators than under Matlab?
Date: Thu, 07 Jun 2012 22:20:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

Why no just make Octave's rand/randn work in Matlab. This is the third
or fourth time I've suggested this over the year with code I posted on
the octave-forge list in 2005 as a mex-file.

http://sourceforge.net/mailarchive/forum.php?thread_name=425A617A.3010004%40motorola.com&forum_name=octave-dev

I've updated this for newer versions of Octave and attach it here.
Compile this file taking the randmtzig.{c,h} files from the Octave
sources. Copy the resulting file to rand.MEXEXT and randn.MEXEXT (where
MEXEXT is returned by the mexext function in matlab) and try something like

rand("state",1:3); rand(1,3)
randn("state",1:3);randn(1,3)

in Matlab and Octave and you should get the same results.

D.


-- 
David Bateman                                address@hidden
35 rue Gambetta                              +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE            +33 6 72 01 06 33 (Mob)

Attachment: rand.c
Description: Text Data


reply via email to

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