Results 1 to 14 of 14

Math Help - Pseudo Random Number Generators

  1. #1
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Question Pseudo Random Number Generators

    How would i decipher the formula to a fixed seed PRNG?

    I can manipulate the PRNG's Seed and Minimum and Maximum Values.

    How would i use this to create a formula that mimics the PRNG's formula?

    Thank you in advance for any help.

    (I wasnt sure which forum to put this in but this forum said algorithms so i guessed it would fit here :P)
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Lightbulb


    Do i need to explain my problem more? Is this even possible to find the formula to the prng?

    I know there is a genius on these forums that can help me somewhere .
    ----------
    Ok so the prng works like this, when i set the seed, it always picks from the top of a list (this list must be generated somehow).

    So, i set the seed to 1.
    I ask for a random number between 0-61.
    I ask again
    Then i set the seed to 1 again.
    I ask again
    Adn again.

    I get the same number pairs. So its not using time or anything like that, literally just the seed number is the seed.

    -----
    So hopefully this will help - i will ask the PRNG for 3 numbers. (Remember if i set the seed again it will show those same 3 numbers).

    I will ask the PRNG for a number between 0-61.

    With a Seed of 0:
    45
    43
    26

    With a Seed of 1:
    57
    54
    11

    With a Seed of 2:
    59
    26
    22

    With a Seed of 3:
    47
    41
    50

    With a Seed of 4:
    11
    16
    16
    ----------

    These number when i set the corresponding seed number i get exactly the same results.

    Is this possible to work out the PRNG formula? Do you think you ould do it if you had more data/results?

    Thank you very much in advance for your help.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Sep 2006
    From
    Between my ears
    Posts
    71
    Thanks
    12
    Are you looking for source code for a Pseudo Random Number Generator? If so, in which language? Do you need a particular distribution?

    There is source code for many Pseudo Random Number Generators posted online. Usually, they output a number between 0 and 1, which you would have to scale for your desired range. You could also use tables to ensure you get the same three numbers all the same for the same seeds.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Smile

    Thanks for the reply

    I need to work out the formula for a working PRNG.

    I believe it to be a relatively simple PRNG, with tables as the numbers get repeated with the same seed.

    Would this be possible to "Decode" a PRNG Formula? How would i go about solving this?

    Thanks again
    - uniflare


    -edit: i will script the formula in php afterwards.
    Last edited by uniflare; July 1st 2008 at 07:35 PM. Reason: see post
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by uniflare View Post

    Do i need to explain my problem more? Is this even possible to find the formula to the prng?

    I know there is a genius on these forums that can help me somewhere .
    ----------
    Ok so the prng works like this, when i set the seed, it always picks from the top of a list (this list must be generated somehow).

    So, i set the seed to 1.
    I ask for a random number between 0-61.
    I ask again
    Then i set the seed to 1 again.
    I ask again
    Adn again.

    I get the same number pairs. So its not using time or anything like that, literally just the seed number is the seed.

    -----
    So hopefully this will help - i will ask the PRNG for 3 numbers. (Remember if i set the seed again it will show those same 3 numbers).

    I will ask the PRNG for a number between 0-61.

    With a Seed of 0:
    45
    43
    26

    With a Seed of 1:
    57
    54
    11

    With a Seed of 2:
    59
    26
    22

    With a Seed of 3:
    47
    41
    50

    With a Seed of 4:
    11
    16
    16
    ----------

    These number when i set the corresponding seed number i get exactly the same results.

    Is this possible to work out the PRNG formula? Do you think you ould do it if you had more data/results?

    Thank you very much in advance for your help.
    Why would you want to do this?

    If you generate 1000000 numbers from a seed how long does the squence take to start repeating itself?

    (from what you have written I see no reason why this has to be a "simple" prng)

    RonL
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Smile

    Im doing it for a game+website

    Ah interesting. with a seed of 0, the pattern does not seem to repeat itself - BUT after 8191 runs, it only outputs 0

    so it stops generating numbers after it has generated 8191 numbers from the same seed.

    Thanks for your help so far i appreciate it
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by uniflare View Post
    Im doing it for a game+website

    Ah interesting. with a seed of 0, the pattern does not seem to repeat itself - BUT after 8191 runs, it only outputs 0

    so it stops generating numbers after it has generated 8191 numbers from the same seed.

    Thanks for your help so far i appreciate it
    and what about other seeds?

    RonL
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Talking

    ok i tested it with a lot of seeds it seems it can only generate 8191 random numbers until it stop producing them - with any seed.

    Does this mean its picking numbers from a table that is 8191 numbers long? And using the seed to start from a seemingly random spot?

    (Or am i way off? lol)

    Thank you so much so far
    Follow Math Help Forum on Facebook and Google+

  9. #9
    Junior Member
    Joined
    Sep 2006
    From
    Between my ears
    Posts
    71
    Thanks
    12
    Any chance you can get a copy of "Numerical Recipes. The Art of Numerical Computing"? There is a chapter there about random numbers, as well as sub-routine source code.

    - - -

    Alternately, "Numerical Methods and Software" also has a chapter about random numbers. In fact, one of the authors has source code for a FORTRAN routine posted on his website (called UNI):

    Random Number Generator

    If you know some FORTRAN, you should be able to translate it.

    - - -

    The NETLIB website is another source of good-quality source code:

    NETLIB Website

    If you do a search on the term "random", perhaps you will find source code for a program you can use. Again, most of these programs are in FORTRAN, so you will have to translate.

    - - -

    There is also the Mersenne Twister, a well-known algorithm with a very long period (in other words, it produces MANY numbers before starting to repeat itself). The Wikipedia page has some good background information, plus many external links that may interest you:

    Wikipedia Mersenne Twister Page

    For example, here is a link to a page with a C++ implementation of the algorithm:

    Mersenne Twister C++ Code

    (Of course, you could also do a Google search for the terms Mersenne and random, and you'd get thousands of other results.)
    Follow Math Help Forum on Facebook and Google+

  10. #10
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by uniflare View Post
    ok i tested it with a lot of seeds it seems it can only generate 8191 random numbers until it stop producing them - with any seed.

    Does this mean its picking numbers from a table that is 8191 numbers long? And using the seed to start from a seemingly random spot?

    (Or am i way off? lol)

    Thank you so much so far
    Are these 8191 numbers from each seed just a shifted copy of one another?

    (Note 8191=2^{13}-1, which is almost certainly significant)

    RonL
    Last edited by CaptainBlack; December 13th 2008 at 10:57 PM. Reason: correct typo 10^13 to 2^13
    Follow Math Help Forum on Facebook and Google+

  11. #11
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Lightbulb

    Sorry david i fear you misunderstand, i dont want any old PRNG i want the one thats producing these results .

    Ok so my tests indicate that that different seeds produce different lists, not shifted, they dont match at all.

    I used an extremely simple scripting language called JASS to figure it out - if you want the code i used feel free to ask.

    Thanks
    Follow Math Help Forum on Facebook and Google+

  12. #12
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Post

    Do you think its still possible? Would it help if i could get more information?

    Thanks - uniflare
    Follow Math Help Forum on Facebook and Google+

  13. #13
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by uniflare View Post
    Do you think its still possible? Would it help if i could get more information?

    Thanks - uniflare
    I'm not prepared to do any more on this, if you want to carry it further read Knuth's "Seminumerical Algorithms" it's volume 2 of "The Art of Computer Programming", which deals with random number generators and their periods etc.

    RonL
    Follow Math Help Forum on Facebook and Google+

  14. #14
    Newbie
    Joined
    Jun 2008
    Posts
    11

    Unhappy

    i dont blame you it seems like pretty heavy math.

    Thanks for the help
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Pseudo-random Numbers
    Posted in the Advanced Statistics Forum
    Replies: 1
    Last Post: March 18th 2011, 02:55 AM
  2. Pseudo random counter decoding
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: July 2nd 2010, 05:22 AM
  3. Number of Generators
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: September 8th 2009, 03:18 PM
  4. Random Number Generation
    Posted in the Advanced Statistics Forum
    Replies: 2
    Last Post: April 25th 2009, 03:59 PM
  5. Final project about random number generators
    Posted in the Advanced Statistics Forum
    Replies: 7
    Last Post: March 12th 2009, 04:58 PM

Search Tags


/mathhelpforum @mathhelpforum