Chapter 08

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 17

Chapter 8

Random-Variate Generation

Banks, Carson, Nelson & Nicol


Discrete-Event System Simulation
Purpose & Overview
 Develop understanding of generating samples
from a specified distribution as input to a
simulation model.

 Illustrate some widely-used techniques for


generating random variates.
 Inverse-transform technique
 Acceptance-rejection technique
 Special properties

2
Inverse-transform Technique
 The concept:
 For cdf function: r = F(x)
 Generate r from uniform (0,1)
 Find x: r = F(x)
x = F-1(r) r1

x1

3
Exponential Distribution [Inverse-transform]

 Exponential Distribution:
 Exponential cdf:

r= F(x)
= 1 – e-  x for x 0
 To generate X1, X2, X3 …

Xi = F-1(R )i

= -(1/ ln(1-R )i [Eq’n 8.3]


Figure: Inverse-transform
technique for exp( = 1)

4
Exponential Distribution [Inverse-transform]

 Example: Generate 200 variates Xi with distribution


exp(= 1)
 Generate 200 Rs with U(0,1) and utilize eq’n 8.3, the histogram
of Xs become:

 Check: Does the random variable X1 have the desired


distribution? P ( X  x ) P ( R F ( x )) F ( x )
1 0 1 0 0

5
Other Distributions [Inverse-transform]

 Examples of other distributions for which inverse


cdf works are:
 Uniform distribution
 Weibull distribution
 Triangular distribution

6
Empirical Continuous Dist’n [Inverse-transform]

 When theoretical distribution is not applicable


 To collect empirical data:
 Resample the observed data
 Interpolate between observed data points to fill in the gaps
 For a small sample set (size n):
 Arrange the data from smallest to largest
x (1) x (2)  x (n)

 Assign the probability 1/(n–1) to each interval x (i -1) x x (i)


ˆ 1  (i  1) 
X F ( R )  x( i  1)  ai  R  
 n 
x( i )  x( i  1) x( i )  x( i  1)
where
ai  
1 / n  (i  1) / n 1/ n

7
Empirical Continuous Dist’n [Inverse-transform]

 Example: Suppose the data collected for 100 broken-


widget repair times are:
Interval Relative Cumulative Slope,
i (Hours) Frequency Frequency Frequency, c i ai
1 0.25 ≤ x ≤ 0.5 31 0.31 0.31 0.81
2 0.5 ≤ x ≤ 1.0 10 0.10 0.41 5.0
3 1.0 ≤ x ≤ 1.5 25 0.25 0.66 2.0
4 1.5 ≤ x ≤ 2.0 34 0.34 1.00 1.47

Consider R 1 = 0.83:

c 3 = 0.66 < R 1 < c 4 = 1.00

X 1 = x (4-1) + a 4(R 1 – c (4-1))


= 1.5 + 1.47(0.83-
0.66)
= 1.75

8
Discrete Distribution [Inverse-transform]

 All discrete distributions can be generated via


inverse-transform technique
 Method: numerically, table-lookup procedure,
algebraically, or a formula
 Examples of application:
 Empirical
 Discrete uniform

9
Discrete Distribution [Inverse-transform]

 Example: Suppose the number of shipments, x, on the


loading dock of IHW company is either 0, 1, or 2
 Data - Probability distribution:
x p(x) F(x)
0 0.50 0.50
1 0.30 0.80
2 0.20 1.00

 Method - Given R, the generation


scheme becomes:

0, 0.0  R 0.5


x 1, 0.5  R 0.8
Consider R 1= 0.73:
2, 0.8  R 1.0
F(x i-1) < R <= F(x )i
F(x 0) < 0.73 <= F(x 1)
Hence, x 1= 1
10
Acceptance-Rejection technique
 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)

Generate R
Procedures:
no
Step 1. Generate R ~ U[0,1]
Condition
Step 2a. If R >= ¼, accept X=R.
yes
Step 2b. If R < ¼, reject R, return to Step 1
Output R’

 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.
11
NSPP [Acceptance-Rejection]

 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,
* = max (t)
 But “accept” only a portion of arrivals, thinning out just enough to
get the desired time-varying rate
Generate E ~ Exp(*)
t=t+E
no

Condition
R <= (t)
yes
Output E ’~ t
12
NSPP [Acceptance-Rejection]

 Example: Generate a random variate for a NSPP


Data: Arrival Rates Procedures:
Step 1. * = max (t) = 1/5, t = 0 and i = 1.
Mean Time
Between Arrival Step 2. For random number R = 0.2130,
t Arrivals Rate l (t) E = -5ln(0.213) = 13.13
(min) (min) (#/min)
t = 13.13
0 15 1/15
Step 3. Generate R = 0.8830
60 12 1/12
120 7 1/7 (13.13)/*=(1/15)/(1/5)=1/3
180 5 1/5 Since R>1/3, do not generate the arrival
240 8 1/8 Step 2. For random number R = 0.5530,
300 10 1/10
E = -5ln(0.553) = 2.96
360 15 1/15
t = 2.96
420 20 1/20
480 20 1/20 Step 3. Generate R = 0.0240
(2.96)/*=(1/15)/(1/5)=1/3
Since R<1/3, T1 = t = 2.96,
and i = i + 1 = 2
13
Special Properties
 Based on features of particular family of
probability distributions
 For example:
 Direct Transformation for normal and lognormal
distributions
 Convolution
 Beta distribution (from gamma distribution)

14
Direct Transformation [Special Properties]

 Approach for normal(0,1):


 Consider two standard normal
random variables, Z1 and Z2,
plotted as a point in the plane:
In polar coordinates:
Z1 = B cos 
Z2 = B sin 

 B2 = Z21 + Z22 ~ chi-square distribution with 2 degrees of freedom


= Exp( = 2). Hence, B   2 ln  R 
 The radius B and angle  are mutually independent.
Z1   2 ln  R1  cos 2 R2 
 independent N 0,1
Z 2   2 ln  R1  sin 2 R2  15
Direct Transformation [Special Properties]

 Approach for normal(,):


 Generate Zi ~ N(0,1)

Xi =  +  Zi

 Approach for lognormal(,):


 Generate X ~ N(,)

Yi = eXi

16
Summary
 Principles of random-variate generate via
 Inverse-transform technique
 Acceptance-rejection technique
 Special properties

 Important for generating continuous and discrete


distributions

17

You might also like