2 Simulasi
Simulasi
Deterministik Probabilistik
Semua data diketahui Melibatkan unsur
sebelumnya. kemungkinan.
Setelah sistem dimulai, kita Kita tahu peluang suatu
tahu pasti apa yang akan kejadian akan terjadi, tapi kita
terjadi tidak tahu kapan kejadian
tersebut terjadi.
Contoh: Contoh:
Memperkirakan jumlah uang Melempar dadu sampai
dalam rekening bank. muncul angka “5”.
Asal Mula Simulasi Monte Carlo
• Game theory
• Quantum mechanics
• Economics
• Cellular automata
• Nuclear weapons
• Computer science (“von
Neumann bottleneck”)
John von Neumann
(1903-1957)
Stanislaw Ulam
Random Number
Secara umum:
r0 = seed
rn = (multiplier * rn -1 + increment) mod modulus, for n > 0
x
f (x)
x
Hampiran Luas Daerah
x, y
(0.2, 0.5)
x
Contoh
f (x)
x, y
x
Hampiran yang Lebih Baik
e2
e3
e1
e4
.60 .68 .78 1.0
e1 e 2 e3 e4
60% 8% 10% 22%
Algoritma Pembangkit Random Number
Berdistribusi Non-Uniform
Diberikan peluang p1, p2, …. untuk kejadian e1, e2, ….
• noise = random
• f = frekuensi; yaitu
kejadian besar yang
jarang terjadi
• pink karena distribusi
uniform sering disebut
“white noise”.
Algoritma Pembangkit Random
Number Berdistribusi Eksponensial
dengan PDF rert, t>0, r<0
• Start with uniform random rand in [0,1)
• Compute ln(rand)/r
2. A hiker without a compass trying to find the way in the dark can step in
any of eight directions (N, NE, E, SE, S, SW, W, NW) with each step. Studies
show that people tend to veer to the right under such circumstances.
Initially, the hiker is facing north. Suppose at each step probabilities of
going in the indicated directions are as follows: N, 19%; NE, 24%; E, 17%;
SE, 10%; S, 2%; SW, 3%; W, 10%; NW, 15%. Develop a simulation to trace a
path of a hiker, and run the simulation a number of times. Describe the
results. (Note that other than at the initial step, this simulation simplifies
the problem by ignoring the direction in which the hiker faces.)