[fpc-pascal] Why is Random(255) some 529x slower compared to Delphi 7?

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Dec 7 16:03:20 CET 2011


On 7 December 2011 14:54, Jonas Maebe <jonas.maebe at ....> wrote:
>
> That's correct. We use the mersenne twister, Delphi probably a linear
> congruential generator. The mersenne twister has a much larger period.

I was reading a bit more about this.  The Mersenne Twister (MT)
generator has a massive period of 2^19937−1, compared to the XorShift
generator, which in turn has a period of 2^128-1.

Most text I read mentions that MT is great for statistical purposes,
and performs well in its class.

So wouldn't it maybe make more sense to let the standard (read more
common) Random() call use a higher performance random number
generator, with a much lower period. Then add the MT generator as a
call to the Maths unit - where more statistical functions are located?

Most applications are not statistical apps, they just want a random
number here or there, so such high period low performance generator is
normally not required. Having it in the Maths unit still makes in
available when needed though - for those specialised apps.

Just a thought...

-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net



More information about the fpc-pascal mailing list