Pseudorandom Number Generators

Slides:



Advertisements
Similar presentations
RSLAB-NTU Lab for Remote Sensing Hydrology and Spatial Modeling 1 An Introduction to R Pseudo Random Number Generation (PRNG) Prof. Ke-Sheng Cheng Dept.
Advertisements

Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
Generating Random Numbers
Random Number Generation Graham Netherton Logan Stelly.
Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
History of Random Number Generators Bob De Vivo Probability and Statistics Summer 2005.
1 Today’s Material Medians & Order Statistics – Ch. 9.
Random Numbers. Two Types of Random Numbers 1.True random numbers: True random numbers are generated in non- deterministic ways. They are not predictable.
Random number generation Algorithms and Transforms to Univariate Distributions.
Computability and Complexity 20-1 Computability and Complexity Andrei Bulatov Random Sources.
Random Number Generators. Why do we need random variables? random components in simulation → need for a method which generates numbers that are random.
Monte-Carlo Techniques Roger Crawfis. June 9, 2015OSU/CIS 5412 Monte-Carlo Integration Overview 1.Generating Psuedo-Random Numbers 2.Multidimensional.
© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 15 Implementation Flaws Part 3: Randomness and Timing Issues.
CSE115/ENGR160 Discrete Mathematics 03/15/11
Stream cipher diagram + + Recall: One-time pad in Chap. 2.
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
Using random numbers Simulation: accounts for uncertainty: biology (large number of individuals), physics (large number of particles, quantum mechanics),
The Problem With The Linpack Benchmark 1.0 Matrix Generator Jack J. Dongarra and Julien Langou International Journal of High Performance Computing Applications.
Simulation.
Statistics.
Cryptography1 CPSC 3730 Cryptography Chapter 9 Public Key Cryptography and RSA.
CSCE Monte Carlo Methods When you can’t do the math, simulate the process with random numbers Numerical integration to get areas/volumes Particle.
Random numbers in Python Nobody knows what’s next...
APPENDIX D RANDOM NUMBER GENERATION
15-853Page :Algorithms in the Real World Generating Random and Pseudorandom Numbers.
Random Number Generation Fall 2013
Random Number Generation Pseudo-random number Generating Discrete R.V. Generating Continuous R.V.
Pseudo-random Number Generation Qiuliang Tang. Random Numbers in Cryptography ► The keystream in the one-time pad ► The secret key in the DES encryption.

MATH 224 – Discrete Mathematics
Random Numbers CSE 331 Section 2 James Daly. Randomness Most algorithms we’ve talked about have been deterministic The same inputs always give the same.
Randomized Algorithms (Probabilistic algorithm) Flip a coin, when you do not know how to make a decision!
Modeling and Simulation
Random-Number Generation Andy Wang CIS Computer Systems Performance Analysis.

CS433 Modeling and Simulation Lecture 15 Random Number Generator Dr. Anis Koubâa 24 May 2009 Al-Imam Mohammad Ibn Saud Islamic University College Computer.
Chapter 7 Random-Number Generation
Module 1: Statistical Issues in Micro simulation Paul Sousa.
Hashing Chapter 20. Hash Table A hash table is a data structure that allows fast find, insert, and delete operations (most of the time). The simplest.
Random Number Generators 1. Random number generation is a method of producing a sequence of numbers that lack any discernible pattern. Random Number Generators.
Pseudo-random generators Random Number Generating There are three types of generators table look-up generators hardware generators algorithmic (software)
Monte Carlo Methods.
Experimental Method and Data Process: “Monte Carlo Method” Presentation # 1 Nafisa Tasneem CHEP,KNU
Monte Carlo Methods So far we have discussed Monte Carlo methods based on a uniform distribution of random numbers on the interval [0,1] p(x) = 1 0  x.
1 HASHING Course teacher: Moona Kanwal. 2 Hashing Mathematical concept –To define any number as set of numbers in given interval –To cut down part of.
Attacks on PRNGs - By Nupura Neurgaonkar CS-265 (Prof. Mark Stamp)
Hashing Basis Ideas A data structure that allows insertion, deletion and search in O(1) in average. A data structure that allows insertion, deletion and.
Pseudorandom numbers John von Neumann: Any one who considers
PRNGs Pseudo-random number generation. Randomness and Cryptography Randomness and pseudo-randomness are useful in cryptography: –To generate random and.
Random numbers in C++ Nobody knows what’s next....
CHAPTER 5 Simulation Modeling. Introduction In many situations a modeler is unable to construct an analytic (symbolic) model adequately explaining the.
R ANDOM N UMBER G ENERATORS Modeling and Simulation CS
Implementation of Public Key Encryption Algorithms
G. Cowan Lectures on Statistical Data Analysis Lecture 5 page 1 Statistical Data Analysis: Lecture 5 1Probability, Bayes’ theorem 2Random variables and.
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
Chapter 3 Generating Uniform Random Variables. In any kind of simulation, we need data, or we have to produce them. Especially in Monte Marco simulation.
UNIFORM RANDOM NUMBER GENERATION Chapter 7 (first half) The goal is to generate a sequence of The goal is to generate a sequence of Uniformly distributed.
1.  How does the computer generate observations from various distributions specified after input analysis?  There are two main components to the generation.
10.Deterministic Randomness 1.Random Sequences Random Sequences A sequence of numbers r 1, r 2,... is random if there are no discernible patterns.
3. Random Number Generator
Generating Random Numbers
A cryptographically secure pseudorandom number generator for Julia
Random numbers Taken from notes by Dr. Neil Moore
Random-Number Generation
Lecture 2 – Monte Carlo method in finance
Computing and Statistical Data Analysis Stat 3: The Monte Carlo Method
Cryptography and Network Security Chapter 7
Computer Simulation Techniques Generating Pseudo-Random Numbers
Generating Random and Pseudorandom Numbers
Generating Random and Pseudorandom Numbers
Presentation transcript:

Pseudorandom Number Generators

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.

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.

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.

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.

Pseudorandom Number Generators Different PRNG’s approximate different properties of random numbers, and desirable properties vary with application. Therefore, different PRNG’s 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.

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

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.

Middle-Square Method - Example Let’s 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…

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.)

Middle-Square Method - Example Let’s try to generate numbers starting with 7600. 7600^2= 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.

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 PRNG’s.

Linear Congruence Method The method uses the following formula: Xn+1 = (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.)

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.

Linear Congruence Method – Choosing Parameters Xn+1 = (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.

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.

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.

Recent PRNG’s – 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 PRNG’s. 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 2^19937-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.)

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.

Summary PRNG’s are algorithms that produce sequences of numbers that simulate randomness. PRNG’s are useful in game design, cryptography, and statistical modeling. Different PRNG’s 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 (n+1)th term. The linear congruence method is defined by the recursive formula Xn+1 = (a * Xn + b) mod c

Sources Carter, Skip. “Linear Congruential Generators.” 9 Jan 1996. Taygeta Scientific Incorporated. 15 Jul 2006 <http://www.taygeta.com/rwalks/node1.html>. "Hardware random number generator." Wikipedia, The Free Encyclopedia. 15 Jul 2006, 04:50 UTC. Wikimedia Foundation, Inc. 17 Jul 2006 <http://en.wikipedia.org/w/index.php?title=Hardware_random_number_generator &oldid=63907837>. Hutchinson, Mark. “An Examination of Visual Basic’s Random Number Generation.” 15 Seconds. 14 Jul 2006 <http://www.15seconds.com/Issue/051110.htm>. "Mersenne twister." Wikipedia, The Free Encyclopedia. 12 Jul 2006, 18:46 UTC. Wikimedia Foundation, Inc. 17 Jul 2006 <http://en.wikipedia.org/w/index.php?title=Mersenne_twister&oldid=63455933>. "Middle-square method." Wikipedia, The Free Encyclopedia. 5 May 2006, 05:06 UTC. Wikimedia Foundation, Inc. 17 Jul 2006 <http://en.wikipedia.org/w/index.php?title=Middle -square_method&oldid=51635932>. “Pseudorandom number generator." Wikipedia, The Free Encyclopedia. 11 Jul 2006, 07:22 UTC. Wikimedia Foundation, Inc. 17 Jul 2006 <http://en.wikipedia.org/w/index.php?title=Pseudorandom_number_generator&oldid=63187601>. "RANDU." Wikipedia, The Free Encyclopedia. 11 May 2006, 11:06 UTC. Wikimedia Foundation, Inc. 17 Jul 2006 <http://en.wikipedia.org/w/index.php?title=RANDU&oldid=52640788>.