CDA6530: Performance Models of Computers and Networks Chapter 5: Generating Random Number and Random Variables TexPoint fonts used in EMF. Read the TexPoint.

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

Generating Random Numbers
Random variables 1. Note  there is no chapter in the textbook that corresponds to this topic 2.
Chapter 8 Random-Variate Generation
Random number generation Algorithms and Transforms to Univariate Distributions.
Lec 18 Nov 12 Probability – definitions and simulation.
Random-Variate Generation. Need for Random-Variates We, usually, model uncertainty and unpredictability with statistical distributions Thereby, in order.
Simulation Modeling and Analysis
Discrete Event Simulation How to generate RV according to a specified distribution? geometric Poisson etc. Example of a DEVS: repair problem.
Agenda Purpose Prerequisite Inverse-transform technique
Statistics.
Generating Continuous Random Variables some. Quasi-random numbers So far, we learned about pseudo-random sequences and a common method for generating.
Random Number Generation
Distinguishing Features of Simulation Time (CLK)  DYNAMIC focused on this aspect during the modeling section of the course Pseudorandom variables (RND)
Random-Variate Generation. 2 Purpose & Overview Develop understanding of generating samples from a specified distribution as input to a simulation model.
Properties of Random Numbers
1 Sampling Distribution Theory ch6. 2  Two independent R.V.s have the joint p.m.f. = the product of individual p.m.f.s.  Ex6.1-1: X1is the number of.
The Monte Carlo Method: an Introduction Detlev Reiter Research Centre Jülich (FZJ) D Jülich
Simulation and Random Number Generation
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
Computer Simulation A Laboratory to Evaluate “What-if” Questions.
Random Number Generation Pseudo-random number Generating Discrete R.V. Generating Continuous R.V.
ETM 607 – Random Number and Random Variates
CDA6530: Performance Models of Computers and Networks Examples of Stochastic Process, Markov Chain, M/M/* Queue TexPoint fonts used in EMF. Read the TexPoint.
CDA6530: Performance Models of Computers and Networks Chapter 2: Review of Practical Random Variables TexPoint fonts used in EMF. Read the TexPoint manual.
Chapter 1 Probability and Distributions Math 6203 Fall 2009 Instructor: Ayona Chatterjee.
Functions of Random Variables. Methods for determining the distribution of functions of Random Variables 1.Distribution function method 2.Moment generating.
MTH 161: Introduction To Statistics
0 Simulation Modeling and Analysis: Input Analysis K. Salah 8 Generating Random Variates Ref: Law & Kelton, Chapter 8.
1 Lesson 3: Choosing from distributions Theory: LLN and Central Limit Theorem Theory: LLN and Central Limit Theorem Choosing from distributions Choosing.

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
Monte Carlo Methods.
CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics Michael Baron. Probability and Statistics for Computer Scientists,
CDA6530: Performance Models of Computers and Networks Chapter 8: Discrete Event Simulation Example --- Three callers problem in homwork 2 TexPoint fonts.
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.
APPENDIX D R ANDOM N UMBER G ENERATION Organization of chapter in ISSO* – General description and linear congruential generators Criteria for “good” random.
Mathematics and Statistics Boot Camp II David Siroky Duke University.
Chapter 2 Random variables 2.1 Random variables Definition. Suppose that S={e} is the sampling space of random trial, if X is a real-valued function.
The Erik Jonsson School of Engineering and Computer Science Chapter 3 pp William J. Pervin The University of Texas at Dallas Richardson, Texas.
CDA6530: Performance Models of Computers and Networks Chapter 8: Statistical Simulation --- Discrete-Time Simulation TexPoint fonts used in EMF. Read the.
ETM 607 – Random-Variate Generation
Chapter 5a:Functions of Random Variables Yang Zhenlin.
Sampling and estimation Petter Mostad
Chapter 19 Monte Carlo Valuation. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Monte Carlo Valuation Simulation of future stock.
Section 10.5 Let X be any random variable with (finite) mean  and (finite) variance  2. We shall assume X is a continuous type random variable with p.d.f.
EMIS 7300 SYSTEMS ANALYSIS METHODS FALL 2005 Dr. John Lipp Copyright © 2005 Dr. John Lipp.
Gil McVean, Department of Statistics Thursday February 12 th 2009 Monte Carlo simulation.
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.
CIS 2033 based on Dekking et al. A Modern Introduction to Probability and Statistics B: Michael Baron. Probability and Statistics for Computer Scientists,
Random number generation
Random Variable 2013.
3. Random Number Generator
Distribution functions
TexPoint fonts used in EMF.
3.1 Expectation Expectation Example
CDA6530: Performance Models of Computers and Networks Project 3 Q&A
TexPoint fonts used in EMF.
TexPoint fonts used in EMF.
Chapter 7 Random Number Generation
Chapter 7 Random-Number Generation
TexPoint fonts used in EMF.
TexPoint fonts used in EMF.
TexPoint fonts used in EMF.
Chapter 8 Random-Variate Generation
CDA6530: Performance Models of Computers and Networks Project 3 Q&A
Berlin Chen Department of Computer Science & Information Engineering
TexPoint fonts used in EMF.
Presentation transcript:

CDA6530: Performance Models of Computers and Networks Chapter 5: Generating Random Number and Random Variables TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAAAAAAAAAA

2 Objective  Use computers to simulate stochastic processes  Learn how to generate random variables  Discrete r.v.  Continuous r.v.  Basis for many system simulations

3 Pseudo Random Number Generation (PRNG)  x n = a x n-1 mod m  Multiplicative congruential generator  x n = {0, 1, , m-1}  x n /m is used to approx. distr. U(0,1)  x 0 is the initial “seed”  Requirements:  No. of variables that can be generated before repetition begins is large  For any seed, the resultant sequence has the “appearance” of being independent  The values can be computed efficiently on a computer

4  x n = a x n-1 mod m  m should be a large prime number  For a 32-bit machine (1 bit is sign)  m= = 2,147,483,647  a = 7 5 = 16,807  For a 36-bit machine  m=  a = 5 5  x n = (ax n-1 + c) mod m  Mixed congruential generator

5 In C Programming Language  Int rand(void)  Return int value between 0 and RAND_MAX  RAND_MAX default value may vary between implementations but it is granted to be at least  X=rand()  X={0,1, , RAND_MAX}  X = rand()%m + n  X={n, n+1, , m+n-1}  Suitable for small m;  Lower numbers are more likely picked

6 (0,1) Uniform Distribution  U(0,1) is the basis for random variable generation  C code (at least what I use): Double rand01(){ double temp; temp = double( rand()+0.5 ) / (double(RAND_MAX) + 1.0); return temp; }

7 Generate Discrete Random Variables ---- Inverse Transform Method  r.v. X: P(X= x j ) = p j, j=0,1,   We generate a PRNG value U~ U(0,1)  For 0<a<b<1, P( a · U <b} = b-a, thus

Example  A loaded dice:  P(1)=0.1; P(2)=0.1; P(3)=0.15; P(4)=0.15  P(5)=0.2; P(6)=0.3  Generate 1000 samples of the above loaded dice throwing results  How to write the Matlab code? 8

9 Generate a Poisson Random Variable  Use following recursive formula to save computation:

10 Some Other Approaches  Acceptance-Rejection approach  Composition approach  They all assume we have already generated a random variable first (not U)  Not very useful considering our simulation purpose

11 Generate Continuous Random Variables ---- Inverse Transform Method  r.v. X: F(x) = P(X· x)  r.v. Y: Y= F -1 (U)  Y has distribution of F. (Y= st X)  P(Y· x) = P(F -1 (U) · x) = P(F(F -1 (U))· F(x)) = P(U· F(x)) = P(X· x)  Why? Because 0<F(x)<1 and the CDF of a uniform F U (y) = y for all y 2 [0; 1]

12 Generate Exponential Random Variable

13 Generate Normal Random Variable --- Polar method  The theory is complicated, we only list the algorithm here:  Objective: Generate a pair of independent standard normal r.v. ~ N(0, 1)  Step 1: Generate (0,1) random number U 1 and U 2  Step 2: Set V 1 = 2U 1 – 1, V 2 = 2U 2 -1  Step 3: If S> 1, return to Step 1.  Step 4: Return two standard normal r.v.:

 Another approximate method- Table lookup  Treat Normal distr. r.v. X as discrete r.v.  Generate a U, check U with F(x) in table, get z 14

15 Generate Normal Random Variable  Polar method generates a pair of standard normal r.v.s X~N(0,1)  What about generating r.v. Y~N(¹, ¾ 2 )?  Y= ¾X + ¹

16 Generating a Random Permutation  Generate a permutation of {1, , n}  Int(kU) +1:  uniformly pick from {1,2, , k}  Algorithm:  P 1,P 2, , P n is a permutation of 1,2, , n (e.g., we can let P j =j, j=1, , n)  Set k = n  Generate U, let I = Int(kU)+1  Interchange the value of P I and P k  Let k=k-1 and if k>1 goto Step 3  P 1, P 2, , P n is a generated random permutation Example: permute (10, 20, 30, 40, 50)

Example of Generating Random Variable  A loaded dice has the pmf:  P(X=1)=P(2)=P(3) =P(4)= 0.1, P(5)=P(6) = 0.3  Generate 100 samples, compare pmf of simulation with pmf of theoretical values  Matlab code is on course webpage samples 1000 samples

18 Monte Carlo Approach ---- Use Random Number to Evaluate Integral  U is uniform distr. r.v. (0,1)  Why?

19  U 1, U 2, , U k are independent generated uniform distr. (0,1)  g(U 1 ), , g(U k ) are independent  Law of large number:

20  Substitution: y=(x-a)/(b-a), dy = dx/(b-a)

21  Generate many g(….)  Compute average value  which is equal to µ