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
Delphi's PRNG, like almost all programming language RTL PRNGs, is a linear congruential generator.
It's good enough for most small-scale things, but there are things to watch out for. In particular, watch out for low-order bits: the pattern of multiplication and add means that low-order bits are not very random at all. But this generally only applies to large 32-bit values pulled out and then truncated with mod
or similar. Using Random(10)
to pluck a value between 0 and 9 internally uses a multiplication over the whole 32-bit range rather than a mod
operation.