[fpc-pascal] Re: Random numbers

Antal antal at componente.net
Mon Mar 6 13:37:25 CET 2006


> |Random numbers should not be generated with a method chosen at random.
> |       -- Donald E. Knuth
>
> |The generation of random numbers is too important to be left to chance.
> |        -- Robert R. Coveyou, Oak Ridge National Laboratory, 1969
>
> The Mersenne Twister Free Pascal uses is one of the best PRNGs known
> today, it just has to be used the right way. But calling it from
> several threads and "randomly" overwriting its state array is
> definitely not the right way to use it.
I'm disappointed, because I compiled the following program (on linux):
rnd.pp
begin
Randomize;
writeln(random(394));
end.

and I ran it for 11 times, and the results are rather strange:
310.
198
344
322*
322*
317-
317-
192
336.
382.
339.
(upon noting the dups I had to re-run again twice, getting:)
120
297.

so, I've got two times a repetition, though I only re-ran the program.
(noted with * and - )
Then I made a new series of random generating:

297.
120
310.
382.
336.
192
317
322
344
198
339.

I only have two problems with these random numbers:
Firstly, I can notice a repetition of some "random" numbers (noted with 
".")
Then also 70% of them are 3xx
I learnt about random numbers, that they do not behave by this way.

Anyway, random numbers are behaving randomly, and we also had a big 
scandal about the national lottery, when (using mechanical methods), 
the occurence of "47" was too frequent in the last ten years, 
and also last year we had around 50% without winners :) (which added 
hundreds of thousands of EURO to the company manager's salary)

So I am really happy with FPC, but this was a bit strange for me.
So it wasn't running simultaneously, but just executing the binary file by 
hand one after another.

I also agree with you Vincent, random numbers must be taken extremly 
carefully. But they also have to care for us :)
Actually I can't recall (though I studied it 10 years ago) which functions 
should increase the entropy.



More information about the fpc-pascal mailing list