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: Mike Miller
Subject: [Octave-bug-tracker] [bug #53299] Several rand/randn bugs with state/seed behavior.
Date: Wed, 7 Mar 2018 18:37:33 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0

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

I'm not sure this is worth pursuing, but I have noticed this odd behavior when
testing the rand functions:


## just started Octave (with --norc), rand generator is in some indeterminate
state
>> init_state = rand ('state');
>> init_seed = rand ('seed');
>> x = rand (100); ## generate a few numbers to shift the state
>> isequal (init_seed, rand ('seed'))  ## NOT using 'seed'
ans = 1
>> isequal (init_state, rand ('state'))
## now let's try to go back to the initial state
>> rand ('state', init_state);
>> y = rand (100);
>> isequal (x, y)
ans = 0
## uh oh, they should be equal, let's try again
>> rand ('state', init_state);
>> z = rand (100);
>> isequal (x, z)
ans = 0
>> isequal (y, z)
ans = 1


As far as I can tell, setting the rand state does reset the rand generator to
a known state and the same sequence is produced. However, when Octave first
starts, the vector that is returned from rand('state') is not the actual
initial state.

    _______________________________________________________

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]