Pertemuan #5 Generating Random Variates Matakuliah : H0332/Simulasi dan Permodelan Tahun : 2005 Versi : 1/1 Pertemuan #5 Generating Random Variates
Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Generating Random Variates
Generating Random Variates Outline Materi Generating Random Variates
Random-Number Generator and Generating Random Variates
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 Fungs F-1 tidak sederhana sehingga lambat membangkitkan random variate
1. General Approaches (cont.) Inverse Transforms Algorithms: Generate U ~ U(0,1) V = F(a) + [F(b) – F(a)] U Return X = F-1(U)
1. General Approaches (cont.) Composition Algorithms: Generate a positive random interger J P(J = j) = pj for j = 1, 2, … Return X with distribution function FJ
1. General Approaches (cont.) Convolution Algorithms: Generate Y1, Y2, …, Ym IID each with distribution function G Return X = Y1, Y2, …, Ym
1. General Approaches (cont.) Acceptance-Rejection Algorithms: Generate Y having density r Generate U ~ U(0,1), independent of Y If return X = Y
1. General Approaches (cont.) Special Properties case by case
2. Generating Random Variates Uniform Algorithms: Generate U ~ U(0,1) Return
2. Generating Random Variates (cont.) Exponential Algorithms: Generate U ~ U(0,1) Return x = - b ln u
2. Generating Random Variates (cont.) Normal The given X ~ N(0,1), we obtain X’ ~ N(m, s) by setting X’ = m + sX Algorithms: Generate U1 and U2 as IID U(0,1), let Vi = 2 Ui – 1 for i = 1, 2, and let W = V12 + V22 If W > 1, go back to step 1. Otherwise, let Then X1 and X2 are IID N(0,1).
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)} Set t = ti-1 Generate U1 and U2 as IID U(0,1) Replace t by t – (1/l*) ln U1 If return ti = t. Otherwise go back to step 2
2. Generating Random Variates (cont.) Poisson Algorithms Nonstationary Poisson Process: Generate U ~ U(0,1) Set t’i = t’i-1 – (1/l) ln U Return ti = L-1(t’i)