Forum > FPC development

PRNG: Why transition to Xoshiro128?

(1/5) > >>

AlanTheBeast:
I recently learned by dint of some experiments on a RaspPi, that FPC seems to be changing the PRNG from the stalwart MersenneTwister to Xoshiro128.

I'm no expert in such, but a little research shows:

MersenneTwister (64) period is 2^19937 - 1, where Xoshiro128 is a mere 2^128 - 1.

To be sure, Xoshiro128 is slightly faster at 0.36 cycles/B, v. MT at 0.62 cycles/B.

Further, MT takes up a lot more room for its state variables: 2504 bytes v. 16 bytes for Xoshiro128.

But, given that most applications are running on machines with gobs of memory, that surely can't be worth losing the 2^19809 X longer period?

Curious:  I searched the forum and don't see any discussion about why this transition is taking place.

Laksen:
If you are serious about random numbers, surely you wouldn't want the Mersenne Twister, but would roll your own to ensure that your distributions have the properties you expect.

I haven't followed any changes to this recently, but if the RTL was changed to something more lightweight I would be a fan. It's a large pitfall for people coming from Delphi, that suddenly the Random() call takes about 10-100x the time.

AlanTheBeast:

It's flat enough for me.  I don't need crytpo grade numbers for my uses.

I guess my real point is : why wasn't this discussed before implementing it.

Kays:

--- Quote from: AlanTheBeast on September 14, 2023, 07:57:24 pm ---PRNG: Why transition to Xoshiro128?

[…] Curious:  I searched the forum and don't see any discussion about why this transition is taking place.
--- End quote ---

--- Quote from: AlanTheBeast on September 14, 2023, 10:32:16 pm ---[…] I guess my real point is : why wasn't this discussed before implementing it.
--- End quote ---
You looked in the wrong place. You search the git history for that. FPC commit 91CF1774 gets us to some discussion in FPC issue 955D.

runewalsh:
Sorry, it was my whim, I like meaningless improvements and persuading the people to apply them with fancy scientific papers. Standard RNG is unusable for anything anyway, not because of the underlying algorithm, but because of its design (pathetic 32-bit seed and the only global state). Even for games, once you’ve gotten a taste of modernity and want to e.g. assign different RNGs to that chest and that monster so that hitting the monster and opening the chest is not different from opening the chest and hitting the monster, and saving and reloading doesn’t affect the outcomes.

Navigation

[0] Message Index

[#] Next page

Go to full version