[fpc-pascal] quality of FPC random

Michael Schnell mschnell at lumino.de
Thu Aug 27 13:48:07 CEST 2015

Thinking more about the issue:

As said, the quality of a random number generator is more a matter of 
taste than a subject to in-depth discussion (as nearly everything that 
is influenced by the way infinity word).

Obviously a perfect random number generator (for integer numbers 0...n) 
*needs *to be able to create a series of a million zeros. This is 
(seemingly) neither a nice Equal Distribution nor *obviously* unpredictable.

IMHO a very decent random generator is just the simple process

r(n) = x(n)   with    x(n) = (a + b*x(n-1) ) mod c

Here c should be a (big) prime, as you will get "less random" sub-series 
of the length of any factor of c.

OK let a and b be big primes, as well. That does not harm.

Equal Distribution is granted, as the sequence will completely cover all 
the numbers 0..c-1 and then start from the beginning.

Of course it is perfectly predictable if you know the numbers a, b, and 
c. and I suppose you can detect them from watching the series for a 
rather short time.

You can reduce the predictability by doing a much smaller non-process 
from the big cyclic process

maybe just

r(n) = x(n) mod d  with    x(n) = (a + b*x(n-1) ) mod c with d being a 
prime several orders of magnitude lower than c (and a and b)

could work (I did not try a proof or disproof). Maybe d needs not be a 
prime but just 2^n if you want an appropriately long key.

But for cryptology all this needs really large integer numbers. That 
should not be an unsolvable problem. Finding a really large Prime is a 
standard task, anyway.

Of course x(0) should be created using a nice entropy method.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150827/17a46bf6/attachment.html>

More information about the fpc-pascal mailing list