Professional Documents
Culture Documents
Random-Variate Generation
f(x)
• Random numbers R, R1, R2, … with
• PDF
⎧1 0 ≤ x ≤ 1
f R ( x) = ⎨
⎩0 otherwise x
0 1
• CDF F(x)
⎧0 x < 0
⎪
FR ( x) = ⎨ x 0 ≤ x ≤ 1
⎪1 x > 1
⎩
x
0 1
F(x) F(x)
1 1
r = F(x) r = F(x)
r1 r1
r2
x x
x1 x2 x1
• Required steps
1. Compute the CDF of the desired random variable X
2. Set F(X) = R on the range of X
3. Solve the equation F(X) = R for X in terms of R
4. Generate uniform random numbers R1, R2, R3, ... and compute
the desired random variate by Xi = F-1(Ri)
0,7
0,6
0,6
0,5
0,5
0,4
0,4
0,3
0,3
0,2 0,2
0,1 0,1
0
0,5
1
1,5
2
2,5
3
3,5
4
4,5
5
5,5
6
6,5
7
0
0,57
1,15
1,72
2,30
2,87
3,45
4,02
4,60
5,17
5,75
Empirical
Histogram
Rel
Prob.
Theor.
PDF
F(X ) = R
X −a
=R
b−a
X − a = R(b − a)
X = a + R(b − a)
• CDF
Xβ
−(αx )
β
β
= − ln(1 − R)
F ( X ) =1 − e α
X β = −α β ⋅ ln(1 − R)
X = β − α β ⋅ ln(1 − R)
X = α ⋅ β − ln(1 − R)
Prof. Dr. Mesut Güneş ▪ Ch. 7 Random-Variate Generation 7.15
Inverse-transform Technique:
Triangular Distribution
• The CDF of a Triangular
Distribution with endpoints
(0, 2) is given by
⎧0 x≤0
⎪ x 2 ⎧ X2
⎪⎪ 2 0 < x ≤1 ⎪⎪ 0 ≤ X ≤1
F ( x) = ⎨ R( X ) = ⎨ 2
(2 − x) 2 ( 2 − X ) 2
⎪1 − 1< x ≤ 2 ⎪1 − 1≤ X ≤ 2
⎪ 2 ⎪⎩ 2
⎪⎩1 x>2
• X is generated by
⎧⎪ 2R 0 ≤ R ≤ 12
X = ⎨
⎪⎩2 − 2(1 − R) 12 < R ≤ 1
⎛ (i − 1) ⎞ (i − 1) i
X = Fˆ −1 ( R) = x(i −1) + ai ⎜ R − ⎟ when <R≤
⎝ n ⎠ n n
R1 = 0.71
X 1 = x( 4−1) + a4 ( R1 − (4 − 1) / n)
= 1.45 + 1.90(0.71 − 0.6)
= 1.66
Consider R1 = 0.83:
• Gamma −∞
• Beta
• The presented method does not work for these
distributions
• Solution
• Approximate the CDF or numerically integrate the CDF
• Problem
• Computationally slow
x P(x) F(x)
0 0.50 0.50
1 0.30 0.80
2 0.20 1.00
F ( xi −1 ) = ri −1 < R ≤ ri = F ( xi )
• Set X = xi
⎧0, R ≤ 0.5
⎪
x = ⎨1, 0.5 < R ≤ 0.8
⎪2, 0.8 < R ≤ 1.0
⎩
Procedure: no
Step 1. Generate R ~ U(0,1)
Condition
Step 2. If R ≥ ¼, accept X=R.
yes
Step 3. If R < ¼, reject R, return to Step 1
Output R’
− ln( Ri )
Ai =
α
• Well known, we derived this generator in the beginning of the class
n n +1
ln ∏ Ri ≥ −α > ln ∏ Ri
i =1 i =1
• Simplify by eln(x) = x n n +1
∏Ri =1
i ≥e −α
> ∏ Ri
i =1
(Z1,Z2)
Z2
α
Z1
k
2 2
• PDF χ =∑X
k i
i =1
1 k −1 − 2x
f ( x, k ) = k x e
2
Γ( k2 )2 2
B = − 2 ln R
• The radius B and angle α are mutually independent.
Z1 = − 2 ln R1 cos( 2πR2 )
Z 2 = − 2 ln R1 sin( 2πR2 )
Xi = µ + σ Zi
Yi = eXi
k
X = ∑ Xi
i =1
k
1
= ∑− ln( Ri )
i =1 kθ
1 ⎛ k ⎞
=− ln⎜⎜ ∏ Ri ⎟⎟
kθ ⎝ i =1 ⎠