Results 1 to 4 of 4

Math Help - Linear congruential generator problem

  1. #1
    Newbie
    Joined
    Jan 2009
    Posts
    2

    Lightbulb 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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by Pontius View Post
    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.

    .

    .
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jan 2009
    Posts
    2
    Quote Originally Posted by Constatine11 View Post
    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.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by Pontius View Post
    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 <p^2

    and:

    m=31607^2 = 999 002 449

    could be used.

    .
    Last edited by Constatine11; January 19th 2009 at 07:25 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 2
    Last Post: July 29th 2010, 06:48 AM
  2. generator of an ideal , I really need help
    Posted in the Advanced Algebra Forum
    Replies: 0
    Last Post: April 13th 2010, 03:02 AM
  3. Generator
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: March 27th 2010, 01:41 AM
  4. Generator of group
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: March 27th 2010, 01:24 AM
  5. generator matrix
    Posted in the Advanced Algebra Forum
    Replies: 7
    Last Post: November 22nd 2008, 01:06 AM

Search Tags


/mathhelpforum @mathhelpforum