Talk:Linear congruential generator: Difference between revisions

→‎On the task: Seed 0 is bad when c = 0.
(→‎On the task: Seed 0 is bad when c = 0.)
Line 14:
:Shouldn't be. Because of the coprimality between a and m, all values from 0 to m-1 will appear exactly once in a cycle, so any seed is as good as another. You may be thinking the situation where people choose ''predictable'' seeds, such as 0, current time, process id, etc while trying to use PRNG for sensitive work, giving an attacker a higher chance of success at finding the pseudo random sequence. --[[User:Ledrug|Ledrug]] 05:23, 7 July 2011 (UTC)
::Aha! Thanks Ledrug. I found what I was thinking of - I was thinking of [[wp:Linear feedback shift register|LFSR's]]. --[[User:Paddy3118|Paddy3118]] 06:52, 7 July 2011 (UTC)
:::There is a class of linear congruential generators where c = 0: the formula is <math>a * r_n \pmod m</math>. If the seed was zero, then these generators would yield zero, zero, zero, zero.... Today, I found that FreeBSD rand() uses such a formula:
:::*<math>r_{n + 1} = 7^5 \times r_n \pmod {2^{31} - 1}</math>
:::If the program tries <math>r_0 = 0</math>, then FreeBSD uses <math>r_0 = 123459876</math>. --[[User:Kernigh|Kernigh]] 04:23, 15 July 2011 (UTC)
 
== Example Sequences==
It occurs to me that the BSD LCRNG can produce an overflow of 32 bit words. It would be nice to have a sequence that exercises this to ensure the behavior is reproduced. --[[User:Dgamey|Dgamey]] 04:58, 8 July 2011 (UTC)
Anonymous user