Agenda Purpose Prerequisite Inverse-transform technique

Slides:



Advertisements
Similar presentations
Statistics review of basic probability and statistics.
Advertisements

Chapter 5 Statistical Models in Simulation
Chapter 5 Discrete Random Variables and Probability Distributions
Sampling Distributions (§ )
CPSC 531:Random-Variate Generation
Chapter 8 Random-Variate Generation
Chapter 8 Random-Variate Generation Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
Chapter 2 Discrete Random Variables
CONTINUOUS RANDOM VARIABLES These are used to define probability models for continuous scale measurements, e.g. distance, weight, time For a large data.
Random-Variate Generation. Need for Random-Variates We, usually, model uncertainty and unpredictability with statistical distributions Thereby, in order.
Simulation Modeling and Analysis
Probability Densities
Simulation Modeling and Analysis
Chapter 6 Continuous Random Variables and Probability Distributions
Random-Variate Generation. 2 Purpose & Overview Develop understanding of generating samples from a specified distribution as input to a simulation model.
28-1 ©2006 Raj Jain Random Variate Generation.
Copyright (c) 2004 Brooks/Cole, a division of Thomson Learning, Inc. Chapter 4 Continuous Random Variables and Probability Distributions.
Properties of Random Numbers
Lecture II-2: Probability Review
4-1 Continuous Random Variables 4-2 Probability Distributions and Probability Density Functions Figure 4-1 Density function of a loading on a long,
Random-Number Generation. 2 Properties of Random Numbers Random Number, R i, must be independently drawn from a uniform distribution with pdf: Two important.
Chapter 4 Continuous Random Variables and Probability Distributions
Random Number Generation Pseudo-random number Generating Discrete R.V. Generating Continuous R.V.
ETM 607 – Random Number and Random Variates
Chapter 5 Sampling and Statistics Math 6203 Fall 2009 Instructor: Ayona Chatterjee.
Simulation Output Analysis
Chapter 5 Statistical Models in Simulation Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
1 Sampling and Sampling Distributions Dr. Jerrell T. Stracener, SAE Fellow Leadership in Engineering EMIS 7370/5370 STAT 5340 : PROBABILITY AND STATISTICS.
Standard Statistical Distributions Most elementary statistical books provide a survey of commonly used statistical distributions. The reason we study these.
 1  Outline  stages and topics in simulation  generation of random variates.
Functions of Random Variables. Methods for determining the distribution of functions of Random Variables 1.Distribution function method 2.Moment generating.
0 Simulation Modeling and Analysis: Input Analysis K. Salah 8 Generating Random Variates Ref: Law & Kelton, Chapter 8.
Chapter 5 Statistical Models in Simulation
Chapter 3 Basic Concepts in Statistics and Probability
Continuous Probability Distributions  Continuous Random Variable  A random variable whose space (set of possible values) is an entire interval of numbers.
Modeling and Simulation CS 313
Modeling and Simulation Input Modeling and Goodness-of-fit tests
Moment Generating Functions
Traffic Modeling.
2 Input models provide the driving force for a simulation model. The quality of the output is no better than the quality of inputs. We will discuss the.
CPSC 531:Input Modeling Instructor: Anirban Mahanti Office: ICT 745
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.
Chapter 7 Random-Number Generation
Use of moment generating functions 1.Using the moment generating functions of X, Y, Z, …determine the moment generating function of W = h(X, Y, Z, …).
Ch5. Probability Densities II Dr. Deshi Ye
LECTURE 25 SIMULATION AND MODELING Md. Tanvir Al Amin, Lecturer, Dept. of CSE, BUET CSE 411.
Chapter 9 Input Modeling Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
4-1 Continuous Random Variables 4-2 Probability Distributions and Probability Density Functions Figure 4-1 Density function of a loading on a long,
Selecting Input Probability Distribution. Simulation Machine Simulation can be considered as an Engine with input and output as follows: Simulation Engine.
ETM 607 – Random-Variate Generation
Statistical Decision Theory Bayes’ theorem: For discrete events For probability density functions.
Random Variable The outcome of an experiment need not be a number, for example, the outcome when a coin is tossed can be 'heads' or 'tails'. However, we.
Input Modeling for Simulation Chapter 3 “As far as the laws of mathematics refer to reality, they are not certain, and as far as they are certain, they.
Review of Probability. Important Topics 1 Random Variables and Probability Distributions 2 Expected Values, Mean, and Variance 3 Two Random Variables.
Chapter 8 Random-Variate Generation Banks, Carson, Nelson & Nicol Discrete-Event System Simulation.
Discrete Random Variables. Introduction In previous lectures we established a foundation of the probability theory; we applied the probability theory.
STA347 - week 91 Random Vectors and Matrices A random vector is a vector whose elements are random variables. The collective behavior of a p x 1 random.
Gil McVean, Department of Statistics Thursday February 12 th 2009 Monte Carlo simulation.
Unit 4 Review. Starter Write the characteristics of the binomial setting. What is the difference between the binomial setting and the geometric setting?
Chap 5-1 Discrete and Continuous Probability Distributions.
Generating Random Variates
Modeling and Simulation CS 313
4-1 Continuous Random Variables 4-2 Probability Distributions and Probability Density Functions Figure 4-1 Density function of a loading on a long,
Random number generation
Modeling and Simulation CS 313
Chapter 8 Random-Variate Generation
Random Variate Generation
Generating Random Variates
Presentation transcript:

Part 7: Random-Variate Generation 4/17/2017 Part 7: Random-Variate Generation

Agenda Purpose Prerequisite Inverse-transform technique Acceptance-rejection technique Special Properties

1. Purpose To generate samples from a specified distribution as input to a simulation model.

2.Prerequisite All the techniques assume that a source of uniform [0,1] random numbers R1, R2, … is readily available, where each Ri has pdf and cdf

3. Inverse-transform Technique (1) 4/17/2017 The concept: For cdf function: r = F(x) Generate r from uniform (0,1) Find x: 1.0 r = F(x) r1 x = F-1(r) F(x) where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X) 0.0 x1 Note 0F(x)1

3. Inverse-transform Technique (2:) Steps to follow Compute the cdf of the desired random variable X Set F(X)=R on the range of X Solve the equation F(X)=R for X in terms of R Generate (as needed) uniform Random Numbers R1, R2, R3, …. and compute the desired random variates by Xi=F-1(Ri)

3. Inverse-transform Technique (3) Exponential Distribution (1) 4/17/2017 Exponential Distribution: Exponential cdf: To generate X1, X2, X3 … One simplification is use to Replace (1-Ri) with Ri as both Ri and (1-Ri) are uniformly distributed on [0,1] Xi = -(1/) ln(Ri) Density f(x)=e-x r = F(x) = 1 – e-lx for x ³ 0 Xi = F-1(Ri) = -(1/l) ln(1-Ri) where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X)

3. Inverse-transform Technique (3) Exponential Distribution (2) (=1) Xi 1 0.1306 0.1400 2 0.0422 0.0431 3 0.6597 1.078 4 0.7965 1.592 5 0.7696 1.468

3. Inverse-transform Technique (3) Exponential Distribution (3) 4/17/2017 Example: Generate 200 variates Xi with distribution exp(l= 1) Generate 200 Ri with U(0,1) and utilize eq’n 8.3, the histogram of Xi becomes: where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X)

3. Inverse-transform Technique (4) Does X have the desired distribution?? Check: Does the random variable X1 generated through transformation have the desired distribution? Remember for Uniform Distribution U(0,1) P(Y≤y)=y for 0 ≤y ≤1

3. Inverse-transform Technique (5) Uniform distribution (1) Consider a random variable X uniformly distributed on the interval [a,b]. The pdf of X is: The cdf is given by: Set F(X)=(X-a)/(b-a)=R Solving for X yields X=a+(b-a)R Therefore the random variate is X=a+(b-a)R

3. Inverse-transform Technique (6) Triangular Distribution Consider a random variable X that has the pdf as: The cdf is given by: For 0X 1, R=X2/2 and for 1X2, R=1-((2-X)2/2) Thus X is generated by:

3. Inverse-transform Technique (7) Empirical Continuous Dist. (1) 4/17/2017 When theoretical distribution is not applicable that provides a good model, then it is necessary to use empirical distribution of data To collect empirical data: One possibility is to resample the observed data itself This is known as using the empirical distribution It makes sense if the input process takes a finite number of values If the data is drawn from a continuous valued input process, then we can interpolate between the observed data points to fill in the gaps This section looks into defining and generating data from a continuous empirical distribution where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X)

3. Inverse-transform Technique (7) Empirical Continuous Dist. (2) 4/17/2017 Given a small sample set (size n): Arrange the data from smallest to largest Define x(0) = 0 Assign the probability 1/n to each interval The resulting empirical cdf has a ith line segment slope as The inverse cdf is calculated by where (i-1)/n<R i/n; R is the random number generated where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X)

3. Inverse-transform Technique (7) Empirical Continuous Dist. (3) Five observations of fire crew response times (in minutes) to incoming alarms are collected to be used in a simulation investigating possible alternative staffing and crew-scheduling policies. The data are: 2.76, 1.83, 0.80, 1.45, 1.24 Arranging in ascending order: 0.80, 1.24, 1.45, 1.83, 2.76 If a random number R1=0.71 is generated, then R1 lies in the fourth interval (between 3/5 and 4/5. Therefore, X1=x (4-1) +a4(R1-(4-1)/n) = 1.66

3. Inverse-transform Technique (7) Empirical Continuous Dist. (4) In general, given ci is the cumulative probability of first i intervals, is the ith interval, then the slope of the ith line segment is: The inverse cdf is calculated as:

3. Inverse-transform Technique (7) Empirical Continuous Dist. (5) 4/17/2017 Example: Suppose the data collected for 100 broken-widget repair times are: Consider R1 = 0.83: c3 = 0.66 < R1 < c4 = 1.00 X1 = x(4-1) + a4(R1 – c(4-1)) = 1.5 + 1.47(0.83-0.66) = 1.75 where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X)

3. Inverse-transform Technique (8) Continuous Distributions with no closed-form inverse A number of useful continuous distributions do not have a closed form expression for their cdf or inverse Examples are: Normal, Gamma, Beta Approximations are possible to inverse cdf A simple approximation to inverse cdf of normal is given by The problems with approximate inverse cdf is that some of them can be computationally intensive

3. Inverse-transform Technique (9) Discrete Distribution (1) 4/17/2017 All discrete distributions can be generated via inverse-transform technique, either numerically through a table-lookup procedure, or algebraically using a formula Examples of application: Empirical Discrete uniform Geometric Gamma where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X)

3. Inverse-transform Technique (9) Discrete Distribution (2) Empirical 4/17/2017 Example: Suppose the number of shipments, x, on the loading dock of a company is either 0, 1, or 2 Data - Probability distribution: Method - Given R, the generation scheme becomes: Consider R1 = 0.73: F(xi-1) < R <= F(xi) F(x0) < 0.73 <= F(x1) Hence, x1 = 1 where r is a variate generated from Uniform (0,1) and F-1(r) is the solution to the equation r = F(X) In general, generate R if F(xi-1) < R <= F(xi) set X=xi

3. Inverse-transform Technique (9) Discrete Distribution (3) Geometric Distribution Consider the Geometric distribution with pmf It’s cdf is given by Using the inverse transform technique, Geometric RV assume the value x whenever,

3. Inverse-transform Technique (9) Discrete Distribution (3) Geometric Distribution Since p is a fixed parameter, let =-1/ln(1-p). Then X=-  ln(1-R)-1. This is nothing but exponentially distributed RV with mean . Therefore, one way to generate a geometric variate with parameter p is to generate exponential variate with parameter -1=-ln(1-p), subtract 1 and Round-up!! Occasionally, there is a need to generate Geometric variate X that can assume values {q, q+1, q+2, …} This can be generated by Most common case is q=1

3. Inverse-transform Technique (9) Discrete Distribution (3) Geometric Distribution Generate three values from a Geometric distribution on the range {X1} with mean 2. This has pmf as Thus X can be generated with q=1, p=1/2 and 1/ln(1-p)=-1.443 R1=0.932, X1=1+ -1.443ln(1-0.932)-1=4 R2=0.105, X1=1+ -1.443ln(1-0.105)-1=1 R3=0.687, X1=1+ -1.443ln(1-0.687)-1=2

4. Acceptance-Rejection Technique(1) Useful particularly when inverse cdf does not exist in closed form, a.k.a. thinning Illustration: To generate random variates, X ~ U(1/4, 1) R does not have the desired distribution, but R conditioned (R’) on the event {R ³ ¼} does. Efficiency: Depends heavily on the ability to minimize the number of rejections. Generate R Condition Output R’ yes no Procedures: Step 1. Generate R ~ U[0,1] Step 2a. If R >= ¼, accept X=R. Step 2b. If R < ¼, reject R, return to Step 1

4. Acceptance-Rejection technique (2) Poisson Distribution (1) Recall a Poisson RV, N with mean >0 has pmf Recall that inter-arrival times A1, A2, … of successive customers are exponentially distributed with rate  (i.e.,  is the mean arrivals per unit time) Then, Relation N=n states that there were exactly n arrivals during one unit of time Second relation states that the nth arrival occurred before time 1 while the (n+1) arrival occurred after time 1. Clearly these two are equivalent

4. Acceptance-Rejection technique (2) Poisson Distribution (2) Recall Ai can be generated by Ai=(-1/)lnRi Therefore,

4. Acceptance-Rejection technique (2) Poisson Distribution (3) Therefore, the procedure for generating a Poisson random variate N is: Step 1: Set n=0; P=1 Step 2: Generate a random number Rn+1 and replace P by P.Rn+1 Step 3: If P < e-, then accept N=n. Otherwise, reject the current n, increase n by one and return to step 2. How many random numbers are required to generate one Poisson variate N? Answer: If N=n, then n+1 random numbers are required. So the average # is: E(N+1)=+1.

4. Acceptance-Rejection technique (2) Poisson Distribution (5) Example Generate three Poisson variates with mean =0.2 First compute e-=0.8187 Step 1: Set n=0, P=1 Step 2: R1=0.4357, P=1.R1=0.4357 Step 3: Since P=0.4357< e-=0.8187, accept N=0 Step 1-3. (R1=0.4146 leads to N=0) Step 1. Set n=0, P=1 Step 2. R1=0.8352, P=1.R1=0.8353 Step 3 Since P e- reject n=0 and return to Step 2 with n=1 Step 2. R2=0.9952, P=R1.R2=0.8313 Step 3 Since P e- reject n=1 and return to Step 2 with n=2 Step 2 R3=0.8004, P=R1.R2.R3=0.6654 Step 3. Since P < e-, accept N=2

4. Acceptance-Rejection technique (2) Poisson Distribution (5) Example The calculations for the generation of these Poisson random variates is summarized as: n Rn+1 P Accept/Reject Result 0.4357 Accept N=0 0.4146 0.8353 Reject 1 0.9952 0.8313 2 0.8004 0.6654 N=2

4. Acceptance-Rejection technique (3) NSPP (1) Non-stationary Poisson Process (NSPP): a Possion arrival process with an arrival rate that varies with time Idea behind thinning: Generate a stationary Poisson arrival process at the fastest rate, l* = max l(t) But “accept” only a portion of arrivals, thinning out just enough to get the desired time-varying rate Generate E ~ Exp(l*) t = t + E no Condition R <= l(t)/* yes Output E ’~ t

4. Acceptance-Rejection technique (3) NSPP (2) Generic algorithm that generates Ti as the time of ith arrival Step 1: Let l* = max l(t) be the maximum arrival rate function and set t=0 and i=1 Step 2: Generate E from the exponential distribution with rate l* and let t=t+E (this is the arrival time of the stationary Poisson process) Step 3: Generate random number R from the U(0,1) distribution. If R l(t)/ l* , then Ti = t and i=i+1

4. Acceptance-Rejection technique (3) NSPP (3) Example: Generate a random variate for a NSPP Data: Arrival Rates Procedures: Step 1. l* = max l(t) = 1/5, t = 0 and i = 1. Step 2. For random number R = 0.2130, E = -5ln(0.213) = 13.13 t = 13.13 Step 3. Generate R = 0.8830 l(13.13)/l*=(1/15)/(1/5)=1/3 Since R>1/3, do not generate the arrival Step 2. For random number R = 0.5530, E = -5ln(0.553) = 2.96 t = 13.13 + 2.96 = 16.09 Step 3. Generate R = 0.0240 l(16.09)/l*=(1/15)/(1/5)=1/3 Since R<1/3, T1 = t = 16.09, and i = i + 1 = 2

5. Special Properties (1) Variate generate techniques that are based on features of particular family of probability distributions For example: Direct Transformation for normal and lognormal distributions Convolution Beta distribution (from gamma distribution)

5. Special Properties (2) Direct Transformation (1) Approach for Normal(0,1): Consider two standard normal random variables, Z1 and Z2, plotted as a point in the plane: B2 = Z21 + Z22 ~ chi-square distribution with 2 degrees of freedom that is equivalent to Exp(l = 2). Hence, The radius B and angle  are mutually independent. In polar coordinates: Z1 = B cos  Z2 = B sin 

5. Special Properties (2) Direct Transformation (2) Approach for Normal(m,s2), N(m,s2): Generate Zi ~ N(0,1) Approach for lognormal(m,s2): Generate X ~ N(m,s2) Xi = m + s Zi Yi = eXi