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

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

[Octave-bug-tracker] [bug #54342] rand() produces different results on o


From: Guillaume
Subject: [Octave-bug-tracker] [bug #54342] rand() produces different results on octave 4.4.0 compared to earlier versions
Date: Wed, 8 Jan 2020 08:25:35 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #20, bug #54342 (project octave):

Matlab and Octave seem to use a different rounding strategy with non integer
positive seeds: Octave using round() (as a consequence of casting to uint32?)
and Matlab using floor().


octave:1> rand('state',42)
octave:2> rand
ans = 0.6394
octave:3> rand('state',42.4)
octave:4> rand
ans = 0.6394
octave:5> rand('state',42.6)
octave:6> rand
ans = 0.038552
octave:7> rand('state',43)
octave:8> rand
ans = 0.038552



>> rand('state',42)
>> rand
ans =
    0.1591
>> rand('state',42.4)
>> rand
ans =
    0.1591
>> rand('state',42.6)
>> rand
ans = 
    0.1591
>> rand('state',43)
>> rand
ans =
    0.3448


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?54342>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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