Simulation Models in Industrial Engineering: Random-Variate Generation
Simulation Models in Industrial Engineering: Random-Variate Generation
INDUSTRIAL ENGINEERING
Lesson 5
Random-Variate Generation
Tran Van Ly
Industrial Engineering & Management
International University
Email: tvly@hcmiu.edu.vn 1
Room: A2-504
Purpose
2. Return X:
X = F-1(R) X
3
Fig. 8.1 Inverse Transform Method
a. Exponential Distribution
• Exponential Distribution:
– Exponential
xe x , x 0 1 e x , x 0
f x F x f (t )dt
0, x 0 0, x 0
– Algorithm
• Generate R ~U(0,1)
• Solve 1-e-λx = R
1
X ln(1 R )
4
b. Uniform Distribution U(a,b)
– Uniform
1
distribution 0; x a
x a
, a xb F x
f x b a , a xb
b a
0, elsewhere 1, x b
– Algorithm
• Generate R~U(0,1)
• Return X = a + (b-a)R
5
c. Weibull Distributions
– Weibull distribution
1 ( x / a )
x e , x0
f ( x )
0 , otherwise
, β are scale and shape parameters
x
( )
F x 1 e
,x 0
– Algorithm
– Generate R~U(0,1)
– Return 1
X [ ln(1 R)]
6
1.2 Empirical Continuous Distributions
• Unable to find theoretical distribution → use empirical distribution
• Procedure:
– Collect data Xi; i= 1, 2, …, n
– Arrange data from smallest to largest
– Assign the probability 1/n to each interval [xi-1, xi]
– Compute the slope of ith line segment
x(i ) x(i 1) x(i ) x(i 1) i/n
ai
i / n (i 1) / n 1/ n R
– Generate R
– Return (i 1)
(i-1)/n
X Fˆ 1 ( R) x(i 1) ai R xi-1 x xi
n
X x( i 1)
ai
R (i 1) / n 7
1.2 Empirical Continuous Distributions (cont.)
• Five observations of fire-crew response times (in mins.):
– 2.76 1.83 0.80 1.45 1.24
– Arranging x0 = 0; x1 = 0.8; x2 = 1.24; x3 = 1.45; x4 = 1.83; x5 = 2.76
– n = 5 probability for each interval = 1/n = 0.2
Cumalative
Interval Probability Probability,
i (Hours) 1/n i/n Slope, a i
1 0.0 ≤ x ≤ 0.80 0.2 0.20 4.00
2 0.8 ≤ x ≤ 1.24 0.2 0.40 2.20
3 1.24 ≤ x ≤ 1.45 0.2 0.60 1.05
4 1.45 ≤ x ≤ 1.83 0.2 0.80 1.90
5 1.83 ≤ x ≤ 2.76 0.2 1.00 4.65
8
1.2 Empirical Continuous Distributions (cont.)
Consider R 1 = 0.71:
9
1. 3 Discrete Distribution
• Procedure P(x)
– With given pmf P(xi) = P(X=xi),
compute cdf
F ( x) P( X x) P( xi )
xi x
(Assume that X can take only the value x1<x2<… <xn) X1 X2 Xi-1 Xi
– Generate R~U(0,1) 1
– Determine the smallest integer I:
R≤ F(xI) R
Return X = xI
F2
X1 X2 Xi-1 Xi
10
1. 3 Discrete Distribution
1
p.m. f : p x ; x 1..k
k
c.d . f :
0 x 1
1
k 1 x 2
2 2 x3
k
F x
...
k 1
k -1 x k
k Generate R~U(0,1)
1 kx If R satisfy:
i 1 i
F i 1 R F i
k k
Then return X = i
11
Bernoulli and Binomial Distribution
Bernoulli Distribution
p.m. f : P X 0 p ; P X 1 1 p
• Generate R~U(0,1)
• If R ≤ p return X = 1, otherwise X = 0
• Return X = Y1 + Y2 + … + Yn
12
2. 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.
13
Poisson Distribution
P x Ri+1 .
•If P < e-λ then accept X = i. Otherwise, reject current i, increase i by
1 and return previous step.
14
3. 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)
15
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
1–/ 2
B2 = Z21 + Z22 ~ chi-square distribution with 2 degrees of freedom =
B (2 ln R)
Exp( = 2). Hence,
– The radius B and angle are mutually independent.
Z1 ( 2 ln R )1/ 2 cos(2R2 )
Z 2 ( 2 ln R )1/ 2 sin( 2R2 )
16
Direct Transformation [Special Properties]
• Approach for normal(,):
– Generate Zi ~ N(0,1)
Xi = + Zi
17
Summary
• Principles of random-variate generate via
– Inverse-transform technique
– Acceptance-rejection technique
– Special properties
• Important for generating continuous and
discrete distributions
18