octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #53299] Several rand/randn bugs with state/see


From: Rik
Subject: [Octave-bug-tracker] [bug #53299] Several rand/randn bugs with state/seed behavior.
Date: Wed, 7 Mar 2018 17:55:07 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #1, bug #53299 (project octave):

At least for bug 2, see
https://www.gnu.org/software/octave/doc/interpreter/Special-Utility-Matrices.html#Special-Utility-Matrices.


The generators operate in the new or old style together, it is not possible to
mix the two. Initializing any generator with "state" or "seed" causes the
others to switch to the same style for future calls.

The state of each generator is independent and calls to different generators
can be interleaved without affecting the final result. For example,

rand ("state", [11, 22, 33]);
randn ("state", [44, 55, 66]);
u = rand (100, 1);
n = randn (100, 1);

and

rand ("state", [11, 22, 33]);
randn ("state", [44, 55, 66]);
u = zeros (100, 1);
n = zeros (100, 1);
for i = 1:100
  u(i) = rand ();
  n(i) = randn ();
end

produce equivalent results. When the generators are initialized in the old
style with "seed" only rand and randn are independent, because the old rande,
randg and randp generators make calls to rand and randn.

The generators are initialized with random states at start-up, so that the
sequences of random numbers are not the same each time you run Octave.7 If you
really do need to reproduce a sequence of numbers exactly, you can set the
state or seed to a specific value.

If invoked without arguments, rand and randn return a single element of a
random sequence.

The original rand and randn functions use Fortran code from RANLIB, a library
of Fortran routines for random number generation, compiled by Barry W. Brown
and James Lovato of the Department of Biomathematics at The University of
Texas, M.D. Anderson Cancer Center, Houston, TX 77030. 




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53299>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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