gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
278 stars 62 forks source link

bug in RANDOM for one seed (=0) with --no-dSFMT + a request #1523

Open alaingdl opened 1 year ago

alaingdl commented 1 year ago

For me, having the possibility to call GDL with --no-dSFMT or using GDL_NO_DSFMT= 1 is very convenient to cross-check the computations using RANDOM in IDL and in GDL since the series are the same, except when seed is set to 0 (zero)

IDL> print, randomn(0,3)  
      2.21221      1.16308     0.774004
IDL> print, randomn(-10,3)                                               
     0.154971      1.11585     -1.35078
IDL> print, randomn(10,3)
    -0.746100      1.00593  -0.00464461

GDL> print, randomn(0,3)
      0.13392     -0.08810      1.67441
GDL> print, randomn(-10,3)  
      0.15497     -1.35078      0.30143
GDL> print, randomn(10,3)
     -0.74610     -0.00464     -0.87205

(as usual I made some tests, looked at the code, play with old and very old GDL versions : persistent bug)

A request

And I have also a request : it would be good to be able to change the status of !GDL.GDL_NO_DSFMT in fligth without to have to restart gdl, but !GDL is ReadOnly as done by sysVarRdOnlyList.push_back( gdl) in initsysvar.cpp. Do you agree I change that status ? (this would be convenient for some tests, including the ones for Coyote lib.)

GillesDuvert commented 1 year ago

seed=0 is a nice trick! IDL generates a different guess as GDL in this case. Good luck to find it! (although inverting the mersenne sequence is possible). BTW the randomn sequence in your example appears to be different btw IDL and GDL when --no-use_dFSMT , but they are not. (???)

You could change !GDL.GDL_NO_DSFMT in flight, but you'll lose the sequence seed, they have not the same size, this may need some work!

alaingdl commented 1 year ago

maybe it is smart to issue a message when explicitly called in this context ?

GillesDuvert commented 1 year ago

Yes, and in the same time, users seem panicked with these messages. We really should make more messages, but enable them only with a commandline switch ( --verbose or the like)