Pseudorandom Number Generators - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Pseudorandom Number Generators

Description:

A random selection of a number from a set or range of numbers is one in which ... Derrick H. Lehmer developed this method in 1951. ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 22
Provided by: nd2
Category:

less

Transcript and Presenter's Notes

Title: Pseudorandom Number Generators


1
Pseudorandom Number Generators
2
Random Number - Definition
  • A random selection of a number from a set or
    range of numbers is one in which each number in
    the range is equally likely to be selected.

3
Applications of Random Numbers
  • Cryptography, games, and many statistical models
    rely on random numbers.
  • Example from cryptography keys for encryption
    of data.
  • Example from games the behavior of a
    computer-controlled character.
  • Example from statistics - the Monte Carlo method.

4
Random Numbers
  • True random numbers can only be generated by
    observations of random physical events, like dice
    throws or radioactive decay.
  • Generation of random numbers by observation of
    physical events can be slow and impractical.

5
Pseudorandom Numbers
  • Instead, sequences of numbers that approximate
    randomness are generated using algorithms.
  • These numbers are inherently nonrandom because
    they are generated by deterministic mathematical
    processes.
  • Anyone who considers arithmetical methods of
    producing random digits is, of course, in a state
    of sin. John von Neumann
  • Hence, these numbers are known as pseudorandom
    numbers.
  • The algorithms used to generate them are called
    pseudorandom number generators.

6
Pseudorandom Number Generators
  • Different PRNGs approximate different properties
    of random numbers, and desirable properties vary
    with application.
  • Therefore, different PRNGs are suitable for
    different applications.
  • For example, a generator that produces
    unpredictable but not uniformly distributed
    number sequences may be useful in cryptography
    but not in the Monte Carlo method.

7
Middle-Square Method - History
  • The middle-square method was first suggested by
    John von Neumann in 1946 for use in models of
    neutron collisions in nuclear reactions.
  • The method was flawed, but it was simple and fast
    enough to be implemented using an ENIAC computer.

John von Neumann
8
Middle-Square Method
  • Begin with an n-digit seed number x0.
  • Square it to obtain a 2n-digit number, adding a
    leading zero if necessary.
  • Take the middle n digits as the next random
    number.
  • Repeat.
  • Numbers generated can be scaled to any interval
    by multiplication and/or addition.

9
Middle-Square Method - Example
  • Lets generate four-digit numbers starting with
    the seed 2041.
  • Square the seed and a leading zero to obtain
    04165681.
  • Take the middle four digits, 1656 as the next
    random number.
  • Repeat to get the following sequence
  • 2041,1656, 7423, 1009, 180, 324, 1049, 1004, 80,
    64, 40,16, 2, 0, 0, 0, 0, 0

10
Middle-Square Method - Flaw
  • This sequence illustrates a serious flaw in the
    middle-square method it tends to degenerate to
    zero. (It degenerates after a number with n/2 or
    less digits is generated.)

11
Middle-Square Method - Example
  • Lets try to generate numbers starting with 7600.
  • 76002 57,760,000, so the next number is also
    7600. If this is repeated, the same number will
    be obtained indefinitely.
  • This example illustrates the importance of
    choosing good seed values (and good parameters
    in general) for pseudorandom number generators.

12
Linear Congruence Method
  • Due to its tendency to quickly degenerate to zero
    and/or repeat, the middle-square method is not a
    very practical algorithm.
  • The linear congruence method provides more
    reliable results.
  • Derrick H. Lehmer developed this method in 1951.
    Since then, it has become one of the most
    commonly used PRNGs.

13
Linear Congruence Method
  • The method uses the following formula
  • Xn1 (a Xn b) mod c
  • given seed value X0 and integer values of a, b,
    and c.
  • (y mod z means the remainder of the division
    of y by z.)

14
Linear Congruence Method Example
  • Let a 1, b 7, c 10, and X0 7.
  • X1 (1 7 7) mod (10) 4
  • Repeat to get the following sequence
  • 7, 4, 1, 8, 5, 2, 9, 6, 3, 0, 7, 4, 1, 5, 2, 9
  • Note that the sequence cycles after every ten
    terms.
  • Pseudorandom numbers always cycle eventually.

15
Linear Congruence Method Choosing Parameters
  • Xn1 (a Xn b) mod c.
  • The period (number of terms in a cycle) depends
    on the choice of parameters .
  • a, b, c and X0 can be chosen such that the
    generator has a full period of c.
  • Large values of c ensure long cycles.

16
Linear Congruence Method - Flaws
  • The cycles of linear congruential generators may
    be too short for some applications.
  • Issues arise from the easily detectable
    statistical interdependence of the members of
    sequences generated with this method. For
    example, it makes the method unsuitable for
    cryptography.
  • The correlation of members of the sequences
    results in the uneven distribution of points
    generated in greater than 2 dimensions.
  • Ordered triples of numbers generated by the
    algorithm lie on a finite number of planes.

17
Linear Congruence Method- RANDU
  • The linear congruential generator RANDU is
    perhaps the most infamous example of a poorly
    chosen set of parameters for a PRNG.
  • The generator was used widely throughout
    scientific community until the fact that ordered
    triples generated by it fell into only fifteen
    planes was taken into account.
  • Many results produced using RANDU are now
    doubted.

3000 triples generated by RANDU.
18
Recent PRNGs Mersenne Twister
  • The Mersenne Twister is now often used in place
    of the linear congruential generator.
  • The Mersenne Twister was developed by
    mathematicians Makoto Matsumoto and Takuji
    Nishimura in 1997.
  • The generator runs faster than all but least
    statistically sound PRNGs.
  • It is distributed uniformly in 623 dimensions.
  • The generator passes numerous tests for
    randomness.
  • The Mersenne Twister gets its name from its huge
    period of 219937-1. This number is a Mersenne
    prime.
  • It would probably take longer to cycle than the
    entire future existence of humanity (and,
    perhaps, the universe.)

19
Mersenne Twister
  • Observing enough numbers generated by the
    Mersenne Twister allows all future numbers to be
    predicted.
  • The Mersenne Twister is, therefore, not suitable
    in cryptography.
  • This illustrates the fact that no single PRNG is
    the best choice for all applications.

20
Summary
  • PRNGs are algorithms that produce sequences of
    numbers that simulate randomness.
  • PRNGs are useful in game design, cryptography,
    and statistical modeling.
  • Different PRNGs are suitable for different
    applications.
  • It is important to choose a good set of
    parameters for a PRNG.
  • The middle-square method uses the middle digits
    of the square of the nth term to generate the
    (n1)th term.
  • The linear congruence method is defined by the
    recursive formula Xn1 (a Xn b) mod c

21
Sources
  • Carter, Skip. Linear Congruential Generators. 9
    Jan 1996. Taygeta Scientific Incorporated. 15
    Jul 2006 lthttp//www.taygeta.com/rwalks/node1.html
    gt.
  • "Hardware random number generator." Wikipedia,
    The Free Encyclopedia. 15 Jul 2006, 0450 UTC.
    Wikimedia Foundation, Inc. 17 Jul
    2006 lthttp//en.wikipedia.org/w/index.php?title
    Hardware_random_number_generator
    oldid63907837gt.
  • Hutchinson, Mark. An Examination of Visual
    Basics Random Number Generation. 15 Seconds.
    14 Jul 2006 lthttp//www.15seconds.com/Issue/051110
    .htmgt.
  • "Mersenne twister." Wikipedia, The Free
    Encyclopedia. 12 Jul 2006, 1846 UTC.
    Wikimedia Foundation, Inc. 17 Jul
    2006 lthttp//en.wikipedia.org/w/index.php?title
    Mersenne_twisteroldid63455933gt.
  • "Middle-square method." Wikipedia, The Free
    Encyclopedia. 5 May 2006, 0506 UTC. Wikimedia
    Foundation, Inc. 17 Jul 2006 lthttp//en.wikipe
    dia.org/w/index.php?titleMiddle -square_metho
    doldid51635932gt.
  • Pseudorandom number generator." Wikipedia, The
    Free Encyclopedia. 11 Jul 2006, 0722 UTC.
    Wikimedia Foundation, Inc. 17 Jul 2006
    lthttp//en.wikipedia.org/w/index.php?titlePseudor
    andom_number_generatoroldid63187601gt.
  • "RANDU." Wikipedia, The Free Encyclopedia. 11 May
    2006, 1106 UTC. Wikimedia Foundation, Inc. 17
    Jul 2006 lthttp//en.wikipedia.org/w/index.ph
    p?titleRANDUoldid52640788gt.
Write a Comment
User Comments (0)
About PowerShow.com