Matakuliah
Tahun
Versi
: H0332/Simulasi dan Permodelan
: 2005
: 1/1
Pertemuan #5
Generating Random Variates
1
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa
akan mampu :
• Generating Random Variates
2
Outline Materi
• Generating Random Variates
3
• Random-Number Generator and Generating Random Variates
1
F(x)
1
U
U(0,1)
0
Generating
Random Variates
x
0
Random-Number
Generator
4
1. General Approaches
• Inverse Transforms
Algorithms:
• Generate U ~ U(0,1)
• Return X = F-1(U)
Kekurangan inverse transform method adalah:
• Tidak semua distribusi memiliki fungsi F-1,
contoh distribusi normal dan gamma
2. Fungs F-1 tidak sederhana sehingga lambat
membangkitkan random variate
5
1. General Approaches (cont.)
• Inverse Transforms
f ( x)
f * ( x) F (b) F (a)
0
0
F ( x) F (a)
F * ( x)
F (b) F (a)
1
if a x b
otherwise
if x a
if a x b
if b x
Algorithms:
• Generate U ~ U(0,1)
• V = F(a) + [F(b) – F(a)] U
• Return X = F-1(U)
6
1. General Approaches (cont.)
• Composition
F ( x) p j F j ( x)
j 1
f ( x) p j f j ( x)
j 1
Algorithms:
1. Generate a positive random interger J
P(J = j) = pj for j = 1, 2, …
2. Return X with distribution function FJ
7
1. General Approaches (cont.)
• Convolution
X Y1 Y2 ... Ym
Algorithms:
• Generate Y1, Y2, …, Ym IID each with distribution
function G
• Return X = Y1, Y2, …, Ym
8
1. General Approaches (cont.)
• Acceptance-Rejection
t ( x) f ( x) for all x
c
t ( x) dx f ( x) dx 1
t ( x)
r ( x)
c
Algorithms:
1. Generate Y having density r
2. Generate U ~ U(0,1), independent of Y
3. If U
f (Y )
return X = Y
t (Y )
9
1. General Approaches (cont.)
• Special Properties
case by case
10
2. Generating Random Variates
• Uniform
Algorithms:
1. Generate U ~ U(0,1)
2. Return
x F 1 (u) a b a u
11
2. Generating Random Variates (cont.)
• Exponential
Algorithms:
1. Generate U ~ U(0,1)
2. Return x = - b ln u
12
2. Generating Random Variates (cont.)
• Normal
The given X ~ N(0,1), we obtain X’ ~ N(m, s) by
setting X’ = m + sX
Algorithms:
1. Generate U1 and U2 as IID U(0,1), let Vi = 2 Ui – 1
for i = 1, 2, and let W = V12 + V22
2. If W > 1, go back to step 1. Otherwise, let
Y
2 ln W
, X 1 V1 Y , and X 2 V2 Y
W
Then X1 and X2 are IID N(0,1).
13
2. Generating Random Variates (cont.)
• Poisson
Algorithms Poisson Processes:
• Generate U ~ U(0,1)
• Return ti = ti-1 – (1/l) ln U
Algorithms Nonstationary Poisson Process:
l*= max {l(t)}
1. Set t = ti-1
2. Generate U1 and U2 as IID U(0,1)
3. Replace t by t – (1/l*) ln U1
4. If U 2 l (t ) / l *
return ti = t.
Otherwise go back to step 2
14
2. Generating Random Variates (cont.)
• Poisson
Algorithms Nonstationary Poisson Process:
t
L(t ) l ( y) dl
0
1. Generate U ~ U(0,1)
2. Set t’i = t’i-1 – (1/l) ln U
3. Return ti = L-1(t’i)
15
© Copyright 2026 Paperzz