CPSC 531: RN Generation1 CPSC 531:Random-Number Generation Instructor: Anirban Mahanti Office: ICT 745 Class Location:

Slides:



Advertisements
Similar presentations
1 Chi-Square Test -- X 2 Test of Goodness of Fit.
Advertisements

Generating Random Numbers
Random Number Generation. Random Number Generators Without random numbers, we cannot do Stochastic Simulation Most computer languages have a subroutine,
 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.
CPSC 531:Random-Variate Generation
Chapter 8 Random-Variate Generation
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.
1 Random Number Generation H Plan: –Introduce basics of RN generation –Define concepts and terminology –Introduce RNG methods u Linear Congruential Generator.
1/55 EF 507 QUANTITATIVE METHODS FOR ECONOMICS AND FINANCE FALL 2008 Chapter 10 Hypothesis Testing.
Random Number Generation
Lecture Inference for a population mean when the stdev is unknown; one more example 12.3 Testing a population variance 12.4 Testing a population.
Distinguishing Features of Simulation Time (CLK)  DYNAMIC focused on this aspect during the modeling section of the course Pseudorandom variables (RND)
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall Statistics for Business and Economics 7 th Edition Chapter 9 Hypothesis Testing: Single.
Experimental Evaluation
Inferences About Process Quality
1 Simulation Modeling and Analysis Pseudo-Random Numbers.
Properties of Random Numbers
The Neymann-Pearson Lemma Suppose that the data x 1, …, x n has joint density function f(x 1, …, x n ;  ) where  is either  1 or  2. Let g(x 1, …,
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
Random Number Generation Fall 2013
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
Chapter 10 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.
CPSC 531: Probability Review1 CPSC 531:Distributions Instructor: Anirban Mahanti Office: ICT Class Location: TRB 101.
CPSC 531:Input Modeling Instructor: Anirban Mahanti Office: ICT 745
Random-Number Generation Andy Wang CIS Computer Systems Performance Analysis.
1 Statistical Distribution Fitting Dr. Jason Merrick.
CPSC 531: Probability Review1 CPSC 531:Probability & Statistics: Review II Instructor: Anirban Mahanti Office: ICT 745
Step 3 of the Data Analysis Plan Confirm what the data reveal: Inferential statistics All this information is in Chapters 11 & 12 of text.
Chapter 7 Random-Number Generation
CS 450 – Modeling and Simulation Dr. X. Topics What Does Randomness Mean? Randomness in games Generating Random Values Random events in real life: measuring.
Tests for Random Numbers Dr. Akram Ibrahim Aly Lecture (9)
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
Random Number Generators 1. Random number generation is a method of producing a sequence of numbers that lack any discernible pattern. Random Number Generators.
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.
Chapter 4 Linear Regression 1. Introduction Managerial decisions are often based on the relationship between two or more variables. For example, after.
APPENDIX D R ANDOM N UMBER G ENERATION Organization of chapter in ISSO* – General description and linear congruential generators Criteria for “good” random.
Tests of Random Number Generators
Chapter 10 Verification and Validation of Simulation Models
Validating a Random Number Generator Based on: A Test of Randomness Based on the Consecutive Distance Between Random Number Pairs By: Matthew J. Duggan,
R ANDOM N UMBER G ENERATORS Modeling and Simulation CS
1 1 Slide © 2008 Thomson South-Western. All Rights Reserved Chapter 12 Tests of Goodness of Fit and Independence n Goodness of Fit Test: A Multinomial.
G. Cowan Lectures on Statistical Data Analysis Lecture 5 page 1 Statistical Data Analysis: Lecture 5 1Probability, Bayes’ theorem 2Random variables and.
Chapter 3: Uncertainty "variation arises in data generated by a model" "how to transform knowledge of this variation into statements about the uncertainty.
Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall Statistics for Business and Economics 8 th Edition Chapter 9 Hypothesis Testing: Single.
Statistical Inference for the Mean Objectives: (Chapter 8&9, DeCoursey) -To understand the terms variance and standard error of a sample mean, Null Hypothesis,
0 Simulation Modeling and Analysis: Input Analysis 7 Random Numbers Ref: Law & Kelton, Chapter 7.
MONTE CARLO METHOD DISCRETE SIMULATION RANDOM NUMBER GENERATION Chapter 3 : Random Number Generation.
1.  How does the computer generate observations from various distributions specified after input analysis?  There are two main components to the generation.
Modeling and Simulation CS 313
STAT 312 Chapter 7 - Statistical Intervals Based on a Single Sample
Modeling and Simulation CS 313
Statistics for Managers using Excel 3rd Edition
Random Number Generators
Chapter 10 Verification and Validation of Simulation Models
Random-Number Generation
Chapter 7 Random Number Generation
Chapter 7 Random-Number Generation
Properties of Random Numbers
Computing and Statistical Data Analysis Stat 3: The Monte Carlo Method
Chapter 8 Random-Variate Generation
Computer Simulation Techniques Generating Pseudo-Random Numbers
Random Number Generation
Presentation transcript:

CPSC 531: RN Generation1 CPSC 531:Random-Number Generation Instructor: Anirban Mahanti Office: ICT Class Location: TRB 101 Lectures: TR 15:30 – 16:45 hours Class web page: Notes from “Discrete-event System Simulation” by Banks, Carson, Nelson, and Nicol, Prentice Hall, Slides derived from the textbook’s website.

CPSC 531: RN Generation2 Properties of Random Numbers r Two important statistical properties: m Uniformity m Independence. r Random Number, R i, must be independently drawn from a uniform distribution with pdf: Figure: pdf for random numbers

CPSC 531: RN Generation3 Generation of Pseudo-Random Numbers r “Pseudo”, because generating numbers using a known method removes the potential for true randomness. r Goal: To produce a sequence of numbers in [0,1] that simulates, or imitates, the ideal properties of random numbers (RN). r Important considerations in RN routines: m Fast m Portable to different computers m Have sufficiently long cycle m Replicable m Closely approximate the ideal statistical properties of uniformity and independence.

CPSC 531: RN Generation4 Techniques for Generating Random Numbers r Linear Congruential Method (LCM). r Combined Linear Congruential Generators (CLCG). r Random-Number Streams.

CPSC 531: RN Generation5 Linear Congruential Method r To produce a sequence of integers, X 1, X 2, … between 0 and m-1 by following a recursive relationship: r The selection of the values for a, c, m, and X 0 drastically affects the statistical properties and the cycle length. r The random integers are being generated [0,m-1], and to convert the integers to random numbers: The multiplier The increment The modulus

CPSC 531: RN Generation6 LCM Example r Use X 0 = 27, a = 17, c = 43, and m = 100. r The X i and R i values are: X 1 = (17*27+43) mod 100 = 502 mod 100 = 2,R 1 = 0.02; X 2 = (17*2+32) mod 100 = 77, R 2 = 0.77; X 3 = (17*77+32) mod 100 = 52, R 3 = 0.52; …

CPSC 531: RN Generation7 Characteristics of a Good Generator r Maximum Density m Such that he values assumed by R i, i = 1,2,…, leave no large gaps on [0,1] m Problem: Instead of continuous, each R i is discrete m Solution: a very large integer for modulus m Approximation appears to be of little consequence r Maximum Period m To achieve maximum density and avoid cycling. m Achieve by: proper choice of a, c, m, and X 0. r Most digital computers use a binary representation of numbers m Speed and efficiency are aided by a modulus, m, to be (or close to) a power of 2.

CPSC 531: RN Generation8 Combined Linear Congruential Generators r Reason: Longer period generator is needed because of the increasing complexity of stimulated systems. r Approach: Combine two or more multiplicative congruential generators. r Let X i,1, X i,2, …, X i,k, be the i th output from k different multiplicative congruential generators. m The j th generator: Has prime modulus m j and multiplier a j and period is m j-1 Produces integers X i,j is approx ~ Uniform on integers in [1, m-1] W i,j = X i,j -1 is approx ~ Uniform on integers in [1, m-2]

CPSC 531: RN Generation9 Combined Linear Congruential Generators m Suggested form: The maximum possible period is: The coefficient: Performs the subtraction X i,1-1

CPSC 531: RN Generation10 Combined Linear Congruential Generators r Example: For 32-bit computers, L’Ecuyer [1988] suggests combining k = 2 generators with m 1 = 2,147,483,563, a 1 = 40,014, m 2 = 2,147,483,399 and a 2 = 20,692. The algorithm becomes: Step 1: Select seeds X 1,0 in the range [1, 2,147,483,562] for the 1 st generator X 2,0 in the range [1, 2,147,483,398] for the 2 nd generator. Step 2: For each individual generator, X 1,j+1 = 40,014 X 1,j mod 2,147,483,563 X 2,j+1 = 40,692 X 1,j mod 2,147,483,399. Step 3: X j+1 = (X 1,j+1 - X 2,j+1 ) mod 2,147,483,562. Step 4:Return Step 5: Set j = j+1, go back to step 2. m Combined generator has period: (m 1 – 1)(m 2 – 1)/2 ~ 2 x 10 18

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

CPSC 531: RN Generation12 Tests for Random Numbers r Two categories: m 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. m 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) / /

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

CPSC 531: RN Generation14 Frequency Tests r Test of uniformity r Two different methods (already discussed …) m Kolmogorov-Smirnov test (look at this again) m Chi-square test

CPSC 531: RN Generation15 Kolmogorov-Smirnov Test r Example: Suppose 5 generated numbers are 0.44, 0.81, 0.14, 0.05, Step 1: Step 2: Step 3: K = max(K +, K - ) = 0.26 Step 4: For  = 0.05, K  α = > K Hence, H 0 is not rejected. Arrange R (j) from smallest to largest K+K+ K-K- R (j) j/N j/N – R (j) R (j) – (j-1)/N

CPSC 531: RN Generation16 Tests for Autocorrelation r Testing the autocorrelation between every m numbers (m is a.k.a. the lag), starting with the i th number  The autocorrelation  im between numbers: R i, R i+m, R i+2m, R i+(M+1)m m M is the largest integer such that r Hypothesis: r If the values are uncorrelated:  For large values of M, the distribution of the estimator of  im, denoted is approximately normal.

CPSC 531: RN Generation17 Tests for Autocorrelation r Test statistics is: m Z 0 is distributed normally with mean = 0 and variance = 1, and:  If  im > 0, the subsequence has positive autocorrelation m High random numbers tend to be followed by high ones, and vice versa.  If  im < 0, the subsequence has negative autocorrelation m Low random numbers tend to be followed by high ones, and vice versa.

CPSC 531: RN Generation18 Autocorrelation Example r Test whether the 3 rd, 8 th, 13 th, and so on, for the following output on P  Hence,  = 0.05, i = 3, m = 5, N = 30, and M = 4 m From Table A.3, z = Hence, the hypothesis is not rejected.

CPSC 531: RN Generation19 Autocorrelation test: Shortcomings r The test is not very sensitive for small values of M, particularly when the numbers being tests are on the low side. r Problem when “fishing” for autocorrelation by performing numerous tests:  If  = 0.05, there is a probability of 0.05 of rejecting a true hypothesis. m If 10 independence sequences are examined, The probability of finding no significant autocorrelation, by chance alone, is = Hence, the probability of detecting significant autocorrelation when it does not exist = 40%

CPSC 531: RN Generation20 Summary r We learnt: m Generation of random numbers m Testing for uniformity and independence r Caution: m Even with generators that have been used for years, some of which still in used, are found to be inadequate. m This chapter provides only the basic m Also, even if generated numbers pass all the tests, some underlying pattern might have gone undetected.