bugGNU Octave - Bugs: bug #57564, Implementation of rng

 
 

bug #57564: Implementation of rng

Submitted by:  Guillaume <gyom>
Submitted on:  Thu 09 Jan 2020 02:43:27 PM UTC  
 
Category:  Octave Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  None Assigned to:  None
Originator Name:  Guillaume Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 10 Jan 2020 11:33:39 AM UTC, comment #4: 
Guillaume <gyom>
Thu 09 Jan 2020 04:33:21 PM UTC, comment #3: 

Setting group, priority, and severity to be consistent with other missing functions.

John W. Eaton <jwe>
Project Administrator
Thu 09 Jan 2020 03:10:50 PM UTC, comment #2: 

The attached file had an UTF-8 encoding issue, re-attaching.

(file #48188)

Guillaume <gyom>
Thu 09 Jan 2020 03:03:33 PM UTC, comment #1: 
  • meaning of seed 0 in Matlab:

https://uk.mathworks.com/matlabcentral/answers/28216-how-to-duplicate-rand-twister-0-in-current-matlab#answer_36510

  • numpy can generate the same sequence of numbers for rand than Matlab:

https://stackoverflow.com/questions/3722138/is-it-possible-to-reproduce-randn-of-matlab-with-numpy?rq=1
https://github.com/numpy/numpy/blob/master/numpy/random/src/mt19937/mt19937.c
so the same could be achieved with Octave. For randn, Matlab seems to be using one or more rand values, which means that it is likely implementing the Ziggurat algorithm (and not the Marsaglia polar method or the Box–Muller transform).

Guillaume <gyom>
Thu 09 Jan 2020 02:43:27 PM UTC, original submission:  

Matlab has a "rng" function to set and query the state of the random number generator:
https://www.mathworks.com/help/matlab/ref/rng.html
This is the recommended syntax. The use of rand('state',...) is discouraged and not documented any more:
https://www.mathworks.com/help/matlab/math/updating-your-random-number-generator-syntax.html
https://www.mathworks.com/help/matlab/ref/rand.html

I attach a possible implementation for Octave. Currently, Octave has a separate generator for rand and randn so rng stores both states: if and when Octave evolves to use a single generator, the rng function can be updated internally without any visible change from the outside. This means that, in my eye, rng can be considered for inclusion in Octave now even if some work is still to take place in rand/randn.

Guillaume <gyom>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48188:  rng.m added by gyom (9KiB - text/x-matlab)
file #48187:  rng.m added by gyom (9KiB - text/x-matlab)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-09 jwe Severity3 - Normal => 1 - Wish
        Priority5 - Normal => 3 - Low
        Item GroupMatlab Compatibility => Feature Request
    2020-01-09 gyom Attached File- => Added rng.m, #48188
    2020-01-09 gyom Attached File- => Added rng.m, #48187

    Back to the top


    Powered by Savane 3.5