6 - Random Variates - 2025
6 - Random Variates - 2025
Chapter 8
Random Numbers
Probability Distributions
Random Variates EXPO(..)
Arrival rate TRIA(..)
Time between arrival NORM(..)
Process time WEIB(..)
Lead time empirical
… …
– Inverse-transform technique
– Acceptance-rejection technique
– Special properties
4
1. Inverse-transform Technique
1.1. Continuous distribution
● The concept: Suppose we
wish to generate a Random
Variate X that is continuous,
has distribution function cdf F:
0 < F(X) <1. Denote F-1 the
inverse of function F.
● The algorithm is F(x)
– For cdf function: R = F(X) 1
R = F(x)
1. Generate R from uniform U(0,1) R
2. Return X:
X = F-1(R) X
Fig. 8.1 Inverse Transform Method5 5
a. Exponential Distribution
● Exponential Distribution:
– Exponential
– Algorithm
● Generate R ~U(0,1)
● Solve 1-e-λx = R
; i= 1, 2, …, n
6
a. Exponential Distribution (cont)
7
8
b. Uniform Distribution U(a,b)
– Uniform distribution
– Algorithm
●Generate R~U(0,1)
●Return X = a + (b-a)R
9
c. Weibull Distributions
– Weibull distribution
– Algorithm
– Generate R~U(0,1)
– Return
10
d. Triangular distribution
11
12
Triangular Distribution (cont)
13
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
i/n
R
– Generate R
(i-1)/n
– Return
xi-1 x xi
14
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
15
1.2 Empirical Continuous Distributions (cont)
Consider R1 = 0.71:
16
1. 3 Discrete Distribution
● Procedure
P(x)
– With given pmf P(xi) = P(X=xi),
compute cdf
(Assume that X can take only the value x 1<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
17
1. 3 Discrete Distribution
18
1. 3 Discrete Distribution
19
1. 3 Discrete Uniform Distribution
Generate R~U(0,1)
If R satisfy:
Then return X = i
20
2. Acceptance-Rejection technique
21
2. Acceptance-Rejection technique
22
2. Acceptance-Rejection technique
g(x) should fully covers the range of f(x) and is easy to sample from
eg. f(x) Norm(0,1) → g(x) Unif(-3,3)
23
2. Acceptance-Rejection technique
24
25
2. Acceptance-Rejection technique
● 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.
26
Mathematical proof
27
28
29
Poisson Distribution
30
Poisson Distribution
•Set n = 0 and P =1
•Generate random number Ri+1 and replace P by
P x Ri+1 .
•If P < e-λ then accept X = n. Otherwise, reject current n, increase n
by 1 and return previous step.
31
Example
Generate three Poisson variates with mean α = 0.2.
32
33
Direct Transformation [Special Properties]
In polar coordinates:
Z1 = B cos φ
Z2 = B sin φ
34
35
Direct Transformation [Special Properties]
Xi = μ + σ Zi
Yi = eXi
36
Summary
THANK YOU.
37