1. Linear congruential generator problem

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

2. Originally Posted by Pontius
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
Why can't you just look up suitable values? I beleive suitable values can be found in Abramowitz and Stegun and in Knuth.

Also I hope this is an excercise and not for use in a simulation, if the latter is the case there are far better PRNG out there available as source code in whatever programming language you require.

.

.

3. Originally Posted by Constatine11
Why can't you just look up suitable values? I beleive suitable values can be found in Abramowitz and Stegun and in Knuth.

Also I hope this is an excercise and not for use in a simulation, if the latter is the case there are far better PRNG out there available as source code in whatever programming language you require.

.

.
Please Constatine... We are in advanced math in the university and know what you told. Our teacher gave us this problem to see if anyone came up with same m, a and c as her. I am sure since you post in this forum that you will be able to help me with my request.

4. Originally Posted by Pontius
Please Constatine... We are in advanced math in the university and know what you told. Our teacher gave us this problem to see if anyone came up with same m, a and c as her. I am sure since you post in this forum that you will be able to help me with my request.
Well the probability of finding the same paparmeters as your teacher are negligable unless you know rather more about her approach than you indicate.

But a simple set of values that meet conditions 1, 2 and 3 are:

$m$ the square of a prime $p$, $a=p+1$, $c$ a prime $

and:

$m=31607^2 = 999 002 449$

could be used.

.