How does the computer generate observations from various distributions specified after input analysis?

Similar documents
How does the computer generate observations from various distributions specified after input analysis?

Independent Events. Two events are independent if knowing that one occurs does not change the probability of the other occurring

Uniform random numbers generators

2008 Winton. Review of Statistical Terminology

Review of Statistical Terminology

B. Maddah ENMG 622 Simulation 11/11/08

Uniform Random Number Generators

CPSC 531: Random Numbers. Jonathan Hudson Department of Computer Science University of Calgary

Slides 3: Random Numbers

Generating Uniform Random Numbers

Generating Uniform Random Numbers

Systems Simulation Chapter 7: Random-Number Generation

Pseudo-Random Generators

Pseudo-Random Generators

Sources of randomness

Topics. Pseudo-Random Generators. Pseudo-Random Numbers. Truly Random Numbers

Generating Uniform Random Numbers

Random Number Generators

Chapter 4: Monte Carlo Methods. Paisan Nakmahachalasint

UNIT 5:Random number generation And Variation Generation

Statistics, Data Analysis, and Simulation SS 2013

Stream Ciphers. Çetin Kaya Koç Winter / 20

Algorithms and Networking for Computer Games

Pseudo-Random Numbers Generators. Anne GILLE-GENEST. March 1, Premia Introduction Definitions Good generators...

Department of Electrical- and Information Technology. ETS061 Lecture 3, Verification, Validation and Input

( ) ( ) Monte Carlo Methods Interested in. E f X = f x d x. Examples:

Generating Random Variables

Monte Carlo Techniques

A Repetition Test for Pseudo-Random Number Generators

Random Number Generation. CS1538: Introduction to simulations

CSCE 564, Fall 2001 Notes 6 Page 1 13 Random Numbers The great metaphysical truth in the generation of random numbers is this: If you want a function

Hands-on Generating Random

Chapter 7 Random Numbers

Stochastic Simulation of Communication Networks

Topics in Computer Mathematics

Lecture 20. Randomness and Monte Carlo. J. Chaudhry. Department of Mathematics and Statistics University of New Mexico

Stochastic Simulation of

Lehmer Random Number Generators: Introduction

Random number generators and random processes. Statistics and probability intro. Peg board example. Peg board example. Notes. Eugeniy E.

B.N.Bandodkar College of Science, Thane. Random-Number Generation. Mrs M.J.Gholba

Uniform Random Binary Floating Point Number Generation

Wednesday, February 21. Today we will begin Course Notes Chapter 5 (Number Theory).

4.5 Applications of Congruences

Random number generation

2 Random Variable Generation

Random number generators

IE 581 Introduction to Stochastic Simulation. One page of notes, front and back. Closed book. 50 minutes. Score

CSE 20 DISCRETE MATH. Winter

MATH 310: Homework 7

Class 12. Random Numbers

Cryptography Lecture 3. Pseudorandom generators LFSRs

Chapter 9 Mathematics of Cryptography Part III: Primes and Related Congruence Equations

Workshop on Heterogeneous Computing, 16-20, July No Monte Carlo is safe Monte Carlo - more so parallel Monte Carlo

Pseudo-random Number Generation. Qiuliang Tang

Section 2.1: Lehmer Random Number Generators: Introduction

cse 311: foundations of computing Fall 2015 Lecture 11: Modular arithmetic and applications

A NEW RANDOM NUMBER GENERATOR USING FIBONACCI SERIES

Simple Unpredictable Pseudo-Random Number Generator

Computer Simulation Techniques: The definitive introduction!

IE 303 Discrete-Event Simulation L E C T U R E 6 : R A N D O M N U M B E R G E N E R A T I O N

Solution: First we need to find the mean of this distribution. The mean is. ) = e[( e 1 e 1 ) 0] = 2.

Number Theory: Applications. Number Theory Applications. Hash Functions II. Hash Functions III. Pseudorandom Numbers

NUMBER THEORY AND CODES. Álvaro Pelayo WUSTL

PROBLEMS ON CONGRUENCES AND DIVISIBILITY

Random processes and probability distributions. Phys 420/580 Lecture 20

Notes. Number Theory: Applications. Notes. Number Theory: Applications. Notes. Hash Functions I

Generating pseudo- random numbers

Statistics 3657 : Moment Approximations

Random numbers and generators

cse 311: foundations of computing Fall 2015 Lecture 12: Primes, GCD, applications

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number

Physics 403 Monte Carlo Techniques

cse 311: foundations of computing Spring 2015 Lecture 12: Primes, GCD, applications

Tae-Soo Kim and Young-Kyun Yang

3 The fundamentals: Algorithms, the integers, and matrices

Random Number Generators - a brief assessment of those available

Number Theory. CSS322: Security and Cryptography. Sirindhorn International Institute of Technology Thammasat University CSS322. Number Theory.

ECEN 5022 Cryptography

Random Numbers. Pierre L Ecuyer

Practice Questions for Final

Chinese Remainder Theorem

Math 109 HW 9 Solutions

arxiv:hep-lat/ v2 10 Aug 1993

BmMT 2017 Individual Round Solutions November 19, 2017

CS March 17, 2009

Integers and Division

Random Number Generators: Metrics and Tests for Uniformity and Randomness

Design of Cryptographically Strong Generator By Transforming Linearly Generated Sequences

EXTRA CREDIT FOR MATH 39

7.2 Applications of Euler s and Fermat s Theorem.

Finite Fields. SOLUTIONS Network Coding - Prof. Frank H.P. Fitzek

Radiation Transport Calculations by a Monte Carlo Method. Hideo Hirayama and Yoshihito Namito KEK, High Energy Accelerator Research Organization

4 Number Theory and Cryptography

Uniform and Exponential Random Floating Point Number Generation

Notation Precedence Diagram

MATH 2112/CSCI 2112, Discrete Structures I Winter 2007 Toby Kenney Homework Sheet 5 Hints & Model Solutions

CSE 20 DISCRETE MATH. Fall

Lecture 5: Random numbers and Monte Carlo (Numerical Recipes, Chapter 7) Motivations for generating random numbers

Definition: A "system" of equations is a set or collection of equations that you deal with all together at once.

Cryptography. P. Danziger. Transmit...Bob...

Transcription:

1

How does the computer generate observations from various distributions specified after input analysis? There are two main components to the generation of observations from probability distributions. 1. Random number generation. 2. Random variate generation. 2

Random number generation The generation of U(0,1) random variates (observations from Uniform (0,1) distribution). This serves as the foundation for the generation of observations from other distributions, which is called random variate generation. Random Number Generator is the term used to describe the procedure and parameters used to generate the U(0,1) observations. 3

Since the stream of random numbers generated is reproducible, random number generation procedures are also referred to as pseudo random number generators. The stream or sequence of numbers produced by a generator should pass statistical tests for randomness. An outside observer should not be able to tell the difference (statistically) between a stream of pseudo random numbers and an actual random number stream. 4

A pseudorandom process appears random, but isn t Pseudorandom sequences exhibit statistical randomness but generated by a deterministic process Pseudorandom sequences are easier to produce than a genuine random sequences Pseudorandom sequences can reproduce exactly the same numbers useful for testing and fixing software. 5

Random number generators typically compute the next number in the sequence from the previous number The first number in a sequence is called the seed to get a new sequence, supply a new seed (current machine time is useful) to repeat a sequence, repeat the seed 6

Desirable Attributes: Uniformity Independence Efficiency Replicability Long Cycle Length 7

Each random number R t is an independent sample drawn from a continuous uniform distribution between 0 and 1 1, 0 x 1 pdf: f(x) = 0, otherwise 8

9 1/12 4 1/ 3 1/ 2) (1/ 3] / [ )] ( [ ) ( 2 1/ 2] / [ ) ( 2 1 0 3 2 1 0 2 1 0 2 1 0 x R E dx x R V x xdx R E x 0f(x) 1 PDF:

One early method the midsquare method (von Neumann and Metropolis 1940) Start with a four digit positive integer Z 0. Square Z 0 to get an integer with up to eight digits (append zeros if less than eight). Take the middle four digits as the next four digit integer Z 1. Place a decimal point to the left of Z 1 to form the first U(0,1) observation. Repeat 10

MidSquare Example: X 0 = 7182 (seed) 2 X 0 = 51581124 ==> R 1 = 0.5811 2 X 0 = (5811) 2 = 33767721 ==> R 2 = 0.7677 etc. 11

Note: Cannot choose a seed that guarantees that the sequence will not degenerate and will have a long period. Also, zeros, once they appear, are carried in subsequent numbers. Ex1: X 0 = 5197 (seed) = 27008809 ==> R 1 = 0.0088 = 00007744 ==> R 2 = 0.0077 Ex2: X 0 = 4500 (seed) = 20250000 ==> R 1 = 0.2500 2= 06250000 ==> R 2 = 0.2500 2 X 0 2 X 1 2 X 0 X 1 12

The prior method does not work well. Degenerates to zero. What are good methods? Linear Congruential Generators (LCGs). Composite generators. Tausworthe generators. 13

Linear Congruential Generators (LCGs). A LCG generates a sequence of integers Z 1, Z 2, Z 3, using the following recursive formula, Z i ( az 1 i c) mod mod m is short for modulo m or the remainder when divided by m. m 14

Since the mod m operation is used, all Z i s will be between 0 and m-1. To get the U(0,1) random observations each Z i generated is divided by m. U 1 Z1 m Z m 2, U 2, So are the U i s really U(0,1) random observations? 15

Let m=63, a=22, c=4 and Z 0 =19. Generate the first five U(0,1) observations. 16

i 22*Z i-1 + 4 Z i U i i 22*Z i-1 + 4 Z i U i i 22*Z i-1 + 4 Z i U i i 22*Z i-1 + 4 Z i U i 0 19 16 356 41 0.6508 32 840 21 0.3333 48 400 22 0.3492 1 422 44 0.6984 17 906 24 0.3810 33 466 25 0.3968 49 488 47 0.7460 2 972 27 0.4286 18 532 28 0.4444 34 554 50 0.7937 50 1038 30 0.4762 3 598 31 0.4921 19 620 53 0.8413 35 1104 33 0.5238 51 664 34 0.5397 4 686 56 0.8889 20 1170 36 0.5714 36 730 37 0.5873 52 752 59 0.9365 5 1236 39 0.6190 21 796 40 0.6349 37 818 62 0.9841 53 1302 42 0.6667 6 862 43 0.6825 22 884 2 0.0317 38 1368 45 0.7143 54 928 46 0.7302 7 950 5 0.0794 23 48 48 0.7619 39 994 49 0.7778 55 1016 8 0.1270 8 114 51 0.8095 24 1060 52 0.8254 40 1082 11 0.1746 56 180 54 0.8571 9 1126 55 0.8730 25 1148 14 0.2222 41 246 57 0.9048 57 1192 58 0.9206 10 1214 17 0.2698 26 312 60 0.9524 42 1258 61 0.9683 58 1280 20 0.3175 11 378 0 0.0000 27 1324 1 0.0159 43 1346 23 0.3651 59 444 3 0.0476 12 4 4 0.0635 28 26 26 0.4127 44 510 6 0.0952 60 70 7 0.1111 13 92 29 0.4603 29 576 9 0.1429 45 136 10 0.1587 61 158 32 0.5079 14 642 12 0.1905 30 202 13 0.2063 46 224 35 0.5556 62 708 15 0.2381 15 268 16 0.2540 31 290 38 0.6032 47 774 18 0.2857 63 334 19 0.3016 17

What will happen after the 63 rd number is generated? m, a, and c are the parameters of the random number generator. There can be an infinite number of different implementations of a LCG. The values used for m, a, and c determine whether the generator is good or bad. 18

The example LCG demonstrates cycling in the prior table. Since m=63, it can generate at most 63 numbers before it repeats the same sequence. This small random number generator has full period since it generates all possible (m=63) numbers before cycling. A long period (full if possible) is desirable since more observations can be generated before cycling. No gaps. 19

The example generator has full period but bad statistical properties (next slide). A good random number generator will have values for m, a, and c such that full or close to full period is obtained, as well as good statistical properties. Crystal Ball m = 2 31 1 a = 62089911 c = 0 Period = 2 31 2 20

Theorem (Hull and Dobell 1962) The LCG Z i = (az i-1 + c) mod m has full period if and only if the following three conditions hold. 1. The only positive integer that exactly divides both m and c is 1. 2. If q is a prime number that divides m, then q divides a-1. 3. If 4 divides m, then 4 divides a-1. The parameters of the LCG dictate the period length of the LCG as well as other properties of the numbers generated. 21

Example: Using the multiplicative congruential method, find the period of the generator for a = 13, m = 2 6, and X 0 = 1, 2, 3, and 4. The solution is given in next slide. When the seed is 1 and 3, the sequence has period 16. However, a period of length eight is achieved when the seed is 2 and a period of length four occurs when the seed is 4. 22

Period Determination Using Various seeds i X i X i X i X i 0 1 2 3 4 1 13 26 39 52 2 41 18 59 36 3 21 42 63 20 4 17 34 51 4 5 29 58 23 6 57 50 43 7 37 10 47 8 33 2 35 9 45 7 10 9 27 11 53 31 12 49 19 13 61 55 14 25 11 15 5 15 16 1 3 23

Types of LCGs When c = 0, the LCG is called a multiplicative generator. When c 0, the LCG is called a mixed generator. Most LCGs implemented are multiplicative Can t have full period. How is m selected. A large period is desired m=2 31 (based on a 32 bit word size). With m=2 31 it has been proven that the period can be at most 2 29 (25% of the values are cycled and gaps may be present). 24

m has been selected as the largest prime number less than m=2 31, which is 2,147,483,647 = 2 31-1. A period of m-1 can be guaranteed if the parameter a is primitive element modulo m. Selections for a that are primitive element modulo m and have been in use are: 16,807 630,360,016 25

LCGs are a special case of the form Z i = g(z i-1, Z i-2,...) (mod m), U i = Z i /m, for some function g Examples: g(z i-1 ) = az i-1 + c LCG g(z i-1, Z i-2,..., Z i-q ) = a 1 Z i-1 + a 2 Z i-2 +... + a q Z i-q multiple recursive generator g(z i-1 ) = a'z 2 i-1 + az i-1 + c quadratic CG g(z i-1, Z i-2 ) = Z i-1 + Z i-2 Fibonacci (bad) 26

Composite Generators Combine two (or more) individual generators in some way. Differencing LCGs Z 1i and Z 2i from LCGs with different moduli Let Z i = (Z 1i Z 2i ) (mod m); U i = Z i / m Very good statistical properties Very portable (micros, different languages) Wichmann/Hill Use three LCGs to get U 1i, U 2i, and U 3i sequences Let U i = fractional part of U 1i + U 2i + U 3i Long period, good statistics, portability 27

Tausworthe Generators Originated in cryptography Generate sequence of bits b1, b2, b3,... via congruence bi = (bi-r + bi-q) (mod 2) = Various algorithms to group bits into Ui s Can achieve very long periods Theoretical appeal: for properly chosen parameters, can prove that over a cycle, mean» 1/2 (as for true U(0,1)) variance» 1/12 (as for true U(0,1)) autocorrelation» 0 (as for true IID sequence) 28