Hi. Not sure if I am posting in the right place.
I need to make a random numbers generator and have some problems with setting some initial values. Hope someone can help me out.
I am thinking I can use the following generator which I found at: Linear congruential generator - Wikipedia, the free encyclopedia
---------- Copied from wikipedia:
where Xn is the sequence of pseudorandom values, and
the "modulus"
the "multiplier"
the "increment" (the special case of c = 0 corresponds to Park–Miller RNG)
the "seed" or "start value" are integer constants that specify the generator.
The period of a general LCG is at most m, and for some choices of a much less than that. The LCG will have a full period if and only if:
1.and
are relatively prime,
2.is divisible by all prime factors of
,
3.is a multiple of 4 if
is a multiple of 4.
------------ Copy end
In my generator the m is set to 999999999 (it can also be a lower number but preferable as close to 999999999 as possible)
X0 and n will be given and be different each time the generator runs.
So what I need help with is to set m, a and c according to the rules above. Remember m should not be altered or if it must be altered then as little as possible downwards.
Hope someone can help me![]()


LinkBack URL
About LinkBacks
where Xn is the
the "
the "multiplier"
the "increment" (the special case of c = 0 corresponds to
the "seed" or "start value" are
and
are
is divisible by all 