|
From: | Alasdair McAndrew |
Subject: | Re: Same sequence of random number generators than under Matlab? |
Date: | Tue, 5 Jun 2012 00:25:48 +1000 |
Writing your own is a good idea. Cleve Moler, here, speaks of the linear congruential generatorx_{k+1} = ax_k (mod m)with a,m = 16807, 2^31-1which was in fact Matlab's internal random number generator until replaced by the Mersenne Twister. You'll find some good links here; there are some PRNGs developed by the late George Marsaglia which are both far simpler, and have a far longer period, than the Mersenne Twister.For a Matlab implementation of the Wichmann-Hill PRNG (which works basically by adding up three floating point values and taking the fractional part as output), seehere. This is a simple program which should work equally well in Matlab and Octave.-AlasdairOn Mon, Jun 4, 2012 at 12:03 AM, Mathieu Dubois <address@hidden> wrote:
Hello,
I want to comapre the output of the Self-Organinzin Map algorithm under Matlab and Octave.
The algorithm is stochastic because, as in most training algorithm, the data are presented inrandom order.
In order to compare as precisely as possible the Matlab and Octave version it seems necessary to have the same sequence of random numbers.
Is there a way to do that?
I have tried the following:
rand('twister', 10);
s = rand(10, 1);
disp(s);
disp(mean(s));
disp(var(s));
The sequences are different (but the statistics are close).
Mathieu
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |