Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,

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

Chapter 7 Hypothesis Testing
1 Chi-Square Test -- X 2 Test of Goodness of Fit.
Generating Random Numbers
Hypothesis Testing A hypothesis is a claim or statement about a property of a population (in our case, about the mean or a proportion of the population)
 1  Outline  generation of random variates  convolution  composition  acceptance/rejection  generation of uniform(0, 1) random variates  linear.
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.
Random Number Generators. Why do we need random variables? random components in simulation → need for a method which generates numbers that are random.
Simulation Where real stuff starts. ToC 1.What, transience, stationarity 2.How, discrete event, recurrence 3.Accuracy of output 4.Monte Carlo 5.Random.
Discrete Event Simulation How to generate RV according to a specified distribution? geometric Poisson etc. Example of a DEVS: repair problem.
1 Random Number Generation H Plan: –Introduce basics of RN generation –Define concepts and terminology –Introduce RNG methods u Linear Congruential Generator.
Simulation.
Random Number Generation
Distinguishing Features of Simulation Time (CLK)  DYNAMIC focused on this aspect during the modeling section of the course Pseudorandom variables (RND)
Basic Business Statistics, 10e © 2006 Prentice-Hall, Inc. Chap 9-1 Chapter 9 Fundamentals of Hypothesis Testing: One-Sample Tests Basic Business Statistics.
Experimental Evaluation
1 Simulation Modeling and Analysis Pseudo-Random Numbers.
Properties of Random Numbers
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
Fall 2011 CSC 446/546 Part 6: Random Number Generation.
Random Number Generation Pseudo-random number Generating Discrete R.V. Generating Continuous R.V.
ETM 607 – Random Number and Random Variates
AM Recitation 2/10/11.
Chapter 13 – 1 Chapter 12: Testing Hypotheses Overview Research and null hypotheses One and two-tailed tests Errors Testing the difference between two.
Overview Definition Hypothesis
Business Statistics, A First Course (4e) © 2006 Prentice-Hall, Inc. Chap 9-1 Chapter 9 Fundamentals of Hypothesis Testing: One-Sample Tests Business Statistics,
Chapter 8 Introduction to Hypothesis Testing
Random Number Generators CISC/QCSE 810. What is random? Flip 10 coins: how many do you expect will be heads? Measure 100 people: how are their heights.
Chapter 9: Testing Hypotheses
Learning Objectives In this chapter you will learn about the t-test and its distribution t-test for related samples t-test for independent samples hypothesis.
Random-Number Generation Andy Wang CIS Computer Systems Performance Analysis.
1 Statistical Distribution Fitting Dr. Jason Merrick.
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.
© 2003, Carla Ellis Simulation Techniques Overview Simulation environments emulation exec- driven sim trace- driven sim stochastic sim Workload parameters.
CPSC 531: RN Generation1 CPSC 531:Random-Number Generation Instructor: Anirban Mahanti Office: ICT Class Location:
Chapter 7 Random-Number Generation
Maximum Likelihood Estimator of Proportion Let {s 1,s 2,…,s n } be a set of independent outcomes from a Bernoulli experiment with unknown probability.
Module 1: Statistical Issues in Micro simulation Paul Sousa.
Basic Concepts in Number Theory Background for Random Number Generation 1.For any pair of integers n and m, m  0, there exists a unique pair of integers.
Modeling and Simulation Random Number Generators
Pseudo-random generators Random Number Generating There are three types of generators table look-up generators hardware generators algorithmic (software)
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.
Lecture 2 Review Probabilities Probability Distributions Normal probability distributions Sampling distributions and estimation.
Lecture 9 Chap 9-1 Chapter 2b Fundamentals of Hypothesis Testing: One-Sample Tests.
Tests of Random Number Generators
Validating a Random Number Generator Based on: A Test of Randomness Based on the Consecutive Distance Between Random Number Pairs By: Matthew J. Duggan,
Issues concerning the interpretation of statistical significance tests.
1 OUTPUT ANALYSIS FOR SIMULATIONS. 2 Introduction Analysis of One System Terminating vs. Steady-State Simulations Analysis of Terminating Simulations.
Math 4030 – 9a Introduction to Hypothesis Testing
Applied Quantitative Analysis and Practices LECTURE#14 By Dr. Osman Sadiq Paracha.
R ANDOM N UMBER G ENERATORS Modeling and Simulation CS
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
Module 9.2 Simulations. Computer simulation Having computer program imitate reality, in order to study situations and make decisions Applications?
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.
MONTE CARLO METHOD DISCRETE SIMULATION RANDOM NUMBER GENERATION Chapter 3 : Random Number Generation.
Random Numbers All stochastic simulations need to “generate” IID U(0,1) “random numbers” Other random variates coming from other distribution can be generated.
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.
P-values.
Random Number Generators
Random-Number Generation
Chapter 7 Random Number Generation
Chapter 7 Random-Number Generation
Properties of Random Numbers
Discrete Event Simulation - 4
Lecture 2 – Monte Carlo method in finance
Computer Simulation Techniques Generating Pseudo-Random Numbers
Random Number Generation
Presentation transcript:

Random Number Generation

Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine, object or function generating random numbers (uniformly distributed) Simulation languages provide more than that (you can get random samples from many distributions) How do they generate it? How can we test their randomness?

Properties of Random Numbers A sequence of random numbers, R 1, R 2,..., must have have two important statistical properties, uniformity and independence Each random number R i, should be an independent sample from the continuous uniform distribution between 0 and 1

Properties of Random Numbers Some consequences of the uniformity and independence properties are If the interval (0,1) is divided into n subintervals of equal length, the expected number of observations in each interval is N/n, where N is the total number of observations The probability of observing a value in a particular interval is independent of the previous values drawn

Pseudo-Random Numbers pseu·do adj. False or counterfeit; fake. [American Heritage Dictionary] Because these numbers are produced using a deterministic algorithm Given the method, the set of random numbers produced can be replicated Thus they are not truly random They simply imitate the properties of uniform distribution and independence A statistical test should conclude they are indistinguishable from true random numbers Thus, they can be used for all practical purposes instead of true random numbers

Considerations in Generating Pseudo-Random Numbers The routine should be fast ( A simulation may require billions of RNs) The routine should be portable to different environments The routine should have a sufficiently long cycle The random numbers generated should be replicable (Useful in debugging and comparing systems) The random numbers generated should imitate the statistical properties of uniformity and independence

Linear Congruential Method This method produces a sequence of integers between 0 and m-1 according to the following recursive relationship: The initial value “X 0 ” is called the seed, “a” the constant multiplier, “c” the increment, and “m” the modulus If c  0, the form is called the mixed congruential method if c = 0, the form is called the multiplicative congruential method The choice of the parameters affect the statistical properties and the cycle length To convert the integers to random numbers use R i = X i /m

Example X 0 = 27, a = 17, c=43, and m = 100 (R i = X i /100) X 0 = 27 X 1 = (17*27+43) mod 100 = 502 mod 100 = 2 (P 1 =.02) X 2 = (17*2+43) mod 100 = 77 mod 100 = 77 (P 2 =.77) X 3 = (17*77+43) mod 100 = 1352 mod 100 = 52 (P 3 =.52)...

Linear Congruential Method Maximum density (no gaps in the distribution): The numbers generated with this method can only assume values from the set I = {0, 1/m, 2/m,..., (m-1)/m} Thus R i ’s are actually distributed with a discrete distribution defined over I This can be accepted as an approximation given that m is large enough Maximum period (avoid cycling, autocorrelation) Cycle length (P) depends on the choice of parameters (always less than m) For m = 2 b, c  0 and relatively prime to m and a = 1+4k, the longest possible period P = m. For m = 2 b, c = 0, X 0 (seed) odd, and a = 3+8k or a = 5+8k, the longest possible period P = m/4 For m a prime number, etc.. P = m-1

Example Use multiplicative congruential method with a = 13, m = 2 6 = 64 and X 0 = 1, 2, 3, 4 X 0 = 1, I = {1, 5, 9,13, …, 53, 57, 61} Gap = 4/64 = (i) XiXi XiXi XiXi XiXi

Combined Linear Congruential Generators To simulate more complex systems, the simulation runs need to go through larger numbers of elementary events This means that kind of simulation runs have to use more random numbers In order to have healthy runs, pseudo-random generators with longer periods are needed (So that cycles can be avoided during the run) It is possible to combine two or more multiplicative congruential generators in such a way that the combined generator has good statistical properties and a longer period

Random-Numbers Streams and Seeds The seed for a random-number generator: Is the integer value X 0 that initializes the random-number sequence. Any value in the sequence can be used to “seed” the generator. A random-number stream: Refers to random numbers obtained by using a starting seed If the streams are b values apart, then stream i could defined by starting seed: Older generators: b = 10 5 ; Newer generators: b = A single random-number generator with k streams can act like k distinct virtual random-number generators To compare two or more alternative systems. Advantageous to dedicate portions of the pseudo-random number sequence to the same purpose in each of the simulated systems.

Pseudo-Random Number Generation in SIMAN SIMAN employs the multiplicative congruential method with a = 16807, m = = 2,147,483,647 This is an almost full-period generator For any initial seed between 1 and , all unnormalized random numbers between 1 and , are generated exactly once before the generator cycles again (P = ) A SIMAN model may employ several different random- number streams Each stream is generated by using the same generator with different initial seed values

Pseudo-Random Number Generation in ARENA With today’s computing power, the cycling can occur in minutes of simulation with with a cycle length of 2 billion (2.1x10 9 ) ARENA thus uses a combined multiple recursive generator which combines two separate generators

Pseudo-Random Number Generation in ARENA The cycle length of this generator is 3.1x10 57 This is inexhaustible with the current computing speeds Just to generate them would take millennia (thousand years) on a 2GHz PC The Arena generator has facility to split this cycle into 1.8x10 9 separate streams, each of length 1.7x10 38 Each stream is further subdivided into 2.3x10 15 separate substreams of length 7.6x10 22 apiece

Tests for Random Numbers Two categories: Testing for uniformity: H 0 : R i ~ U[0,1] H 1 : R i ~ U[0,1] Failure to reject the null hypothesis, H 0, means that evidence of non- uniformity has not been detected. Testing for independence: H 0 : R i ~ independently H 1 : R i ~ independently Failure to reject the null hypothesis, H 0, means that evidence of dependence has not been detected. Level of significance  the probability of rejecting H 0 when it is true:  = P(reject H 0 |H 0 is true) / /

Tests for Random Numbers When to use these tests: If a well-known simulation languages or random-number generators is used, it is probably unnecessary to test If the generator is not explicitly known or documented, e.g., spreadsheet programs, symbolic/numerical calculators, tests should be applied to many sample numbers. Types of tests: Theoretical tests: evaluate the choices of m, a, and c without actually generating any numbers Empirical tests: applied to actual sequences of numbers produced.