I am writing a program which write statistical tests in Delphi (must be Delphi) and I've heard that the Random functionality is somewhat odd. You have to call randomize to randomize the seed of the random function when the program starts.
I'm wondering if the random function (after calling randomize) is random enough for statistical tests or a Mersenne twister is needed? Does anyone have any insight into random's actual implementation which can tell me how important this is?
From the Embarcadero web site:
_lrand is the long random number generator function. _rand uses a multiplicative congruential random number generator with period 2^64 to return successive pseudo-random numbers in the range from 0 to 2^31 - 1.
The generator is reinitialized by calling srand with an argument value of 1. It can be set to a new starting point by calling srand with a given seed number.
If they didn't change the implementation since I analyzed it(Delphi 4 IIRC), the Delphi PRNG is implemented like this:
(Pseudocode/assume the multiplications are on arbitrarily large integers)
Return random between 0..9
Note:Check FloatToStr(Random) length before use or use any other digit from the decimal part...