modelica / ModelicaStandardLibrary

Free (standard conforming) library to model mechanical (1D/3D), electrical (analog, digital, machines), magnetic, thermal, fluid, control systems and hierarchical state machines. Also numerical functions and functions for strings, files and streams are included.
https://doc.modelica.org
BSD 3-Clause "New" or "Revised" License
484 stars 168 forks source link

Update PRNGs in ModelicaRandom.c? #2836

Open beutlich opened 5 years ago

beutlich commented 5 years ago

When ModelicaRandom.c was introduced with the Noise package for MSL v3.2.2 the xorshift PRNGs from http://xoshiro.di.unimi.it/xorshift.php were utilized. These PRNGs are now superseded by xoshiro, which according to the authors at http://xoshiro.di.unimi.it are faster and better.

@MartinOtter @tobolar @HansOlsson What do you think?

HansOlsson commented 5 years ago

It seems like an improvement.

But I don't think increasing the performance and those statistical properties is high priority.

A concern for any change of PRNG is that we provide the possibility to select a seed to be able to reproduce simulations - and changing PRNG will break that. Hopefully it is sufficient to just document that it has changed - and anyone really concerned about reproducing simulation will have a copy of the old library.

beutlich commented 5 years ago

It seems like an improvement.

Exactly.

A concern for any change of PRNG is that we provide the possibility to select a seed to be able to reproduce simulations - and changing PRNG will break that. Hopefully it is sufficient to just document that it has changed - and anyone really concerned about reproducing simulation will have a copy of the old library.

Note that compatibility already is broken (and documented) in v3.2.3 w.r.t. v3.2.2 due to #2252.

tobolar commented 5 years ago

Modelica counterparts of the C implementation are Modelica.Math.Random.Generators.Xorshift.... Changing PRNGs will require to rename those classes as well or to add new ones. So the user will be clearly informed about the change. ... and introducing MSL v4 will make it even easier (I guess) to get rid of xorshift-based generators.

MartinOtter commented 5 years ago

You are right, xoshiro should be used at some point in the future. However, I would wait and not do it now, because making this change in a correct way might be difficile and requires thorough testing (e.g. as I recall, one low order random number generator is used to initialize a high order random generator and one would have to dig in all these codes to figure out that all this still works with the improved generators).