1 / 17

Generating Random Numbers

Generating Random Numbers. a presentation by: Matthew Jobrack. What is randomness?. Governed by, or involving equal chance for each item. Two Categories. There are two basic categories of methods for generating random numbers: Physical Methods (Hardware Random Number Generation)

lfrancois
Download Presentation

Generating Random Numbers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generating Random Numbers a presentation by: Matthew Jobrack

  2. What is randomness? Governed by, or involving equal chance for each item.

  3. Two Categories There are two basic categories of methods for generating random numbers: • Physical Methods (Hardware Random Number Generation) • Computational Methods • Humans (really bad at this)* We will now take an adventure through each of these methods, and then discover how randomness is tested!

  4. Physical Methods • The most early, primitive forms of random number generation (originally used for gambling) fell into this category. • This includes methods such as dice rolling, coin flipping and other things you might still see in gambling today. • These methods can be pretty random, but very slow, and can have several other problems.

  5. Physical Methods • In modern times, several physical methods have been discovered to generate random numbers, usually based on natural phenomena that are inherently unpredictable.

  6. Physical Methods These methods include: • Measuring time intervals between radioactive decays using a Geiger counter. • Clock drift (minute differences in synchronized clocks) • White noise on a radio

  7. Physical Methods • Hardware random number generation is safer for encryption purposes. • However, in many cases it is less practical. • Physical random number generators are also prone to “breaking” and becoming less random, with no obvious signs that it has done so.

  8. Computational Methods • Pseudo-Random number generators (PRNG) are algorithms designed to produce a sequence of numbers that pass tests for statistical randomness. • They are programmable algorithms though, and are therefore not completely random. • If you used these enough, you would begin to find periodic patterns. They approximate the properties of random numbers.

  9. Computational Methods There are several advantages to PRNGs: • They are programmable, and therefore obviously very convenient. • They are reproducible. • They are much faster.

  10. Computational Methods There are many different types of PRNGs, including but not limited to: • Middle Square Method • Lagged Fibonacci Generators • Linear Congruential Generators • Mersenne Twister • Linear Feedback Registers • Blum Blum Shub

  11. Middle Square Method For a generator of n-digit numbers, the period using this method can be no longer than 8n. All this method involves is squaring a number, then taking its middle digits. Ex. • To generate 6-digit numbers, start with a random seed, say, 675248. • Square this number to get: 455959861504. • Take the middle 6 digits of this number to get the next random number: 959861. This method has several problems, one of which is that the sequence of numbers often converge to 0.

  12. Lagged Fibonacci Generators Random numbers generated by: Where is some binary operation. m is often a power of 2, such as 232 or 264. This is to help a computer calculate faster, because if m is 2p, the computer can divide by 2p and calculate the remainder by truncating all but the rightmost 2p digits. The maximum period depends on the binary operation used, and on values of j and k. This means that arbitrarily choosing j and k may not result in a very random sequence. Using this method, a computer must also keep track of the previous k numbers in the sequence.

  13. Linear Congruential Generators Random numbers generated recursively by: Again, choosing m to be a power of 2 is the most efficient choice, in terms of computer power. However, choosing this modulus can lead to less randomness. The period length is at most m, but whether or not the sequence achieves a period of this length is very sensitive to the choices of a and c. In particular, the period length will be m iff: • c and m are relatively prime, and • a-1 is divisibe by all prime factors of m • a-1 is a multiple of 4 if m is a multiple of 4

  14. Linear Congruential Generators Advantages: • They are very easily (quickly) calculated • The are decently random Disadvantages: • Not super random • In particular, there is a serial correlation between successive values. If we plot successive 3 points on a 3 dimensional plot, they will not be truly random points, and will lie on various planes. • The RANDU number generator, which uses the recurrence Was used in the 60’s and 70’s, before people realized that it fails practically every random number test.

  15. Mersenne Twister • Can produce a period of 219937-1 with the correct choice of parameters. • Passes almost all tests for statistical randomness. • Uses a working area of only 624 words. • There are no efficient algorithms with integers using a Mersenne twister. • The Mersenne twister uses polynomial algebra over the two-element field. • The recurrence is defined: For k=(0,1,2,..). The seed is given as x1, x2, …, xn-1.

  16. Blum Blum Shub Method If M is the product of 2 large primes which are congruent to 3 (mod4), then this method is the recurrence: The seed should be chosen such that it is coprime to M. • This PRNG is notable because each number in the sequence can be calculated directly.

  17. Tests for Randomness • Frequency test • Serial test • Poker test • Gap test • Diehard tests

More Related