Announcement

Collapse
No announcement yet.

Random number generation

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Random number generation



    One for the techies...


    I need to generate a few hundred random numbers for reasons too uninteresting to relate. I understand the distinction between "true" random numbers (generated by physical phenomena such as atomic decay) and pseudo random numbers (generated by computers).


    Without a computer science background, I am not sure of how exactly the computer is using the computer clock as a seed.


    So the questions are: How exactly is the computer's clock used as a seed, and what exactly is the clock?


    Second: I'm aware that the limitations of physical memory on the computer will give rise to repetition in the sequence: how exactly does the memory constraint give rise to this?


    Thanks in advance for your help, and apologies in advance for posting such a dry thread![img]smileys/redface.gif[/img]

    #2


    lots of links here but I'd imagine you have already looked through most of these


    http://en.wikipedia.org/wiki/Random_number_generation
    The only difference between me and a madman is that I'm not mad.
    - Salvador Dali (1904-1989)

    Comment


      #3
      thanks, had read that link alright

      Comment


        #4
        Hi snamh, a pseudo-random sequence of numbers will always give the same sequence of numbers given the same initial starting point (the seed). This reproducibility is often desired. Sometimes its not - e.g. for encryption algorithms. In the second case, it's common to seed the pseudo-random sequence of numbers with a different seed each time you use it - often the clock in a PC suffices. In your case, it sounds like setting the initial seed to 0 would suffice for your needs. I dunno how you are generating your numbers but you might consider just using the rand() function in excel as the basic building block. It should suffice for common or everyday needs.



        Comment


          #5


          Originally posted by suaf
          Hi snamh, a pseudo-random sequence of numbers will always give the same sequence of numbers given the same initial starting point (the seed). This reproducibility is often desired. Sometimes its not - e.g. for encryption algorithms. In the second case, it's common to seed the pseudo-random sequence of numbers with a different seed each time you use it - often the clock in a PC suffices. In your case, it sounds like setting the initial seed to 0 would suffice for your needs. I dunno how you are generating your numbers but you might consider just using the rand() function in excel as the basic building block. It should suffice for common or everyday needs.



          Thanks for that, I was aware that that it is possible to generate the same sequence from the same starting seed (which is often what is required in Monte Carlo analysis). I think the question I had was: how exactly does a program take information from the clock to use as a seed? Does it look up the clock's value at the time the program is executed, and use that number as the seed? If so, how does this give rise to the problem of repeating sequences of numbers? Is it simply the problem that affects all arithmetically generated random numbersor is there something especially problematic about relying on the clock as a seed?


          I'm aware of the rand() function and have used it before, but I need some comfort as to the robustness of pseudo generators, including excel.

          Comment


            #6


            Can you not just tear up small strips of paper, put a number on themand pull them out of a hat?


            Truly random!


            Otherwise, random numbers from a PCare never really random. There is always a common denominator i.e a seed which precludes randomness.
            Please support Milford Hospice. Click here to donate.

            Comment


              #7
              It depends on what the PRBS is being used for. If the PRBS is part of a security subsystem, the mechanim for determining the seed is usually made complex as an attacker will often attempt to crack the crypto algorithm at the PRBS seeding. If not, typically, programs look up the clock at the time the program executes and use that as the seed, they often run an algorithm over the clock before using as the seed. It depends. Using the clock as the source of the seed is cryptographically weak as an attacker simply logs the sequence of PRBS numbers generated - assumes one of the common PRBS algorithms, deduces the seed used. Does that a few times, and figures out the PRBS algorithm, and that fact that the PRBS is being seeded from a clock. You may or may not care about that. More sophisticated seeding algorithms often run a service, on something like a PC, gathering entropy - e.g. keystroke patterns, mouse patterns, hard-disk write patterns, etc and store up a difficult-to-guess seed from those for use the next time the application is started - but that's pretty heavy stuff. However, no matter what you do to seed the sequence, nothing will really make your PRBS more "random".

              Comment


                #8


                Originally posted by Snamh

                how exactly does a program take information from the clock to use as a seed? Does it look up the clock's value at the time the program is executed, and use that number as the seed? If so, how does this give rise to the problem of repeating sequences of numbers? Is it simply the problem that affects all arithmetically generated random numbersor is there something especially problematic about relying on the clock as a seed?
                Yup, the program just takes the clock (generally given as a number of seconds/milliseconds since a given datum) and use that as the intial number.

                The problem of "true" randomness isn't directly due to the clock (although, if you could generate a "true" random seed, you could generate a "true" random number - but if you can generate a "true" random seed you don't need a random number generator in the first place! [img]smileys/wink.gif[/img] )

                The problem of generating a random number is more procedural. How do you get a computer to generate a random number - ask it to pick a number between 1 and 10? Computers can't do that, they need an algorithm to follow to generate a number. Without some kind of random input ("Please enter tonight's lotto numbers, and I'll give you a true random number") the numbers generated won't be truly random.
                Munster - Incessant Perfervidity
                "Ireland Will Choke" - Jeremy Guscott

                Comment


                  #9
                  If you are concerned about the "quality" of the random numbers you are currently generating, you might consider playing with DieHarder, at http://www.phy.duke.edu/~rgb/General/rand_rate.php which provides pretty good pseudo-random number generators and can evaluate the output of your existing PRNG.

                  Comment


                    #10


                    Originally posted by suaf
                    It depends on what the PRBS is being used for. If the PRBS is part of a security subsystem, the mechanim for determining the seed is usually made complex as an attacker will often attempt to crack the crypto algorithm at the PRBS seeding. If not, typically, programs look up the clock at the time the program executes and use that as the seed, they often run an algorithm over the clock before using as the seed. It depends. Using the clock as the source of the seed is cryptographically weak as an attacker simply logs the sequence of PRBS numbers generated - assumes one of the common PRBS algorithms, deduces the seed used. Does that a few times, and figures out the PRBS algorithm, and that fact that the PRBS is being seeded from a clock. You may or may not care about that. More sophisticated seeding algorithms often run a service, on something like a PC, gathering entropy - e.g. keystroke patterns, mouse patterns, hard-disk write patterns, etc and store up a difficult-to-guess seed from those for use the next time the application is started - but that's pretty heavy stuff. However, no matter what you do to seed the sequence, nothing will really make your PRBS more "random".

                    Don't need for encryption, I'm relieved to say! As I said above, I'm aware that arithmetical numbers aren't truly random (because you can predict the sequence on the basis of the rule). I'm using it to select a random sample from a population, and will map the cases to pseudo-randomly generated integers to select cases to be sampled, and I am about to be grilled on random generation for this purpose, and I am aware that the scale of what I'm proposing doesn't require any massive thought given to the character of the algorithm for generation but I wanted some degree of comfort before having my ass raked over the coals.


                    On the second question, why do physical memory limitations give rise to repetition in the number sequence?

                    Comment


                      #11


                      Originally posted by suaf
                      If you are concerned about the "quality" of the random numbers you are currently generating, you might consider playing with DieHarder, at http://www.phy.duke.edu/~rgb/General/rand_rate.php which provides pretty good pseudo-random number generators and can evaluate the output of your existing PRNG.

                      Had seen that thanks, but would be overkill for what I need, just wanted to clarify the method, and the nature of pseudo generation

                      Comment


                        #12
                        Originally posted by who?
                        Originally posted by Snamh


                        how exactly does a program take information from the clock to use as a seed? Does it look up the clock's value at the time the program is executed, and use that number as the seed? If so, how does this give rise to the problem of repeating sequences of numbers? Is it simply the problem that affects all arithmetically generated random numbersor is there something especially problematic about relying on the clock as a seed?

                        Yup, the program just takes the clock (generally given as a number of seconds/milliseconds since a given datum) and use that as the intial number.

                        The problem of "true" randomness isn't directly due to the clock (although, if you could generate a "true" random seed, you could generate a "true" random number - but if you can generate a "true" random seed you don't need a random number generator in the first place! [img]smileys/wink.gif[/img] )

                        The problem of generating a random number is more procedural. How do you get a computer to generate a random number - ask it to pick a number between 1 and 10? Computers can't do that, they need an algorithm to follow to generate a number. Without some kind of random input ("Please enter tonight's lotto numbers, and I'll give you a true random number") the numbers generated won't be truly random.

                        Ok, so its just the fact that it is an arithmetical method, and not something intrinsically dodgy about using the clock. cheers

                        Comment


                          #13
                          You're more likely to be asked have you checked the randomness of your data and how you checked it and if you've achieved randomness across the range of values you need. For example using a PRNG to generate random numbers between 0 and 255 when you need numbers in the range 0 .. 511 (or worse still generating random numbers between 0 and 255 and multiplying the output by 2 to get the right range but losing all odd numbers), that type of thing ...

                          Comment


                            #14
                            Sure I'll just blind them with science "Well, the reason the results are sowonky is because of the seeding the computer clock loike"

                            Comment


                              #15


                              <a href=\"http://www.xboxlc.com/profile/Ruck_You\" target=\"_blank\">
                              http://www.xboxlc.com/cards/sig/default/Ruck%20You.jpg
                              </a>

                              If you’re fat stay in the ruck - Liam Toland

                              Comment

                              Working...
                              X