MONTE CARLO SIMULATION MATH 182
SIMULATION Simulation of a process – the examination of any emulating process simpler than that under consideration. Examples: System’s Simulation such as simulation of engineering systems, large organizational systems, and governmental systems Operational Gaming such as military gaming and business gaming Monte Carlo Simulation Agent-Based simulation
AGENT-BASED SYSTEMS Using Netlogo
MONTE CARLO SIMULATION The process is similar to gambling in casinos such as using roulette wheels, dice and playing cards. Monte Carlo is a technique for selecting numbers randomly from a probability distribution (not necessarily from a standard distribution).
MONTE CARLO SIMULATION The computer-generated random numbers are called pseudo- random numbers.
A PSEUDO-RANDOM NUMBER GENERATOR ≈FOLLOWING Uniform Distribution [0,1] Linear Congruential Generator (LCG) Period=m–1 x0 ≠0 is the seed number Example: a=13, b=0, m=31, x0 =8 Hence, u0 =0.2581; x1 =11, u1=0.3548 Minimal Standard Random Number Generator: a=75, b=0, m=231–1 (a Mersenne prime)
EXAMPLE 1 DEMAND RANGE OF RANDOM NUMBER Let rϵ{1,2,…,100} 10 1-20 15 21-50 20 51-100 A simple example:
IF(B2<=20,10,IF(B2<=50,15,20)) Example 1 Run Random Number Simulated Demand 1 83 20 2 45 15 3 48 4 14 10 5 52 6 7 67 8 42 9 81 73 11 21 12 22 13 77 Sample Formula: ROUNDUP(RAND()*100,0) IF(B2<=20,10,IF(B2<=50,15,20))
example 1 So the average demand is: Using simulation (15 runs): 16.333… Using expected value: 0.2*10+0.3*15+0.5*20=16.5 Notice that Monte Carlo simulation is just a statistical experiment.
State1 State2 State3 State4 ANOTHER EXAMPLE: State1 State2 State3 State4 RAND RAND RAND RAND RAND
Integration by MC Simulation Generate n random sequence xi є [a,b], then for m clusters of runs If you want to consolidate your m clusters of runs into just one cluster.
RAND()*5 CLUSTER RUNS 1 RAND CLUSTER RUNS 2 CLUSTER RUNS 3 3.58 12.81 1.22 1.49 4.29 18.37 0.76 0.58 1.12 1.26 1.46 2.12 4.50 20.22 2.68 7.17 4.58 20.93 4.90 24.02 4.74 22.49 0.33 0.11 3.97 15.77 0.26 0.07 3.89 15.11 3.50 12.25 2.04 4.15 0.80 0.64 5.00 24.96 2.25 5.07 1.58 2.49 2.17 4.72 0.08 0.01 0.73 0.53 2.83 8.00 4.66 21.75 3.31 10.94 1.62 2.62 4.54 20.63 2.64 6.95 Ave SUM(B2:B11)/10*5 62.98 42.04 39.09 48.04
Integration by MC Simulation Generate n random sequence xi є [a,b], n random sequence yi є [c,d] and n random sequence zi є [e,f] , then for m clusters of runs If you want to consolidate your m clusters of runs into just one cluster.
HIT OR MISS MONTE CARLO Find the AREA of the set of points (x,y) inside the unit square x,yϵ[0,1] that satisfy: Area=(length of interval1)x(length of interval2)x(number of hits)/(total count of generated random pairs) Area≈0.547
HIT OR MISS MONTE CARLO Find the VOLUME:
IF(AND(A3^2+B3^2<=C3^2,A3^2+B3^2+(C3-1)^2<=1),1,0) x y z count RAND()*2-1 RAND()*2 IF(AND(A3^2+B3^2<=C3^2,A3^2+B3^2+(C3-1)^2<=1),1,0) 0.142973094 -0.166680645 1.407409063 1 -0.783836654 -0.936474685 1.659525168 -0.272318721 0.131424335 0.899121291 0.309445838 -0.02570091 0.717548985 -0.770113876 -0.638294195 0.509448198 0.475610449 0.012623621 0.507359561 0.644456842 0.19929642 0.36582555 -0.04857905 0.476761013 0.167943641 -0.222669404 0.803157266 1.339139434 1 0.987939698 -0.642931976 0.836244323 -0.115050608 -0.189584746 0.361764572 0.815099685 0.757810953 0.243549675 -0.045867733 -0.675279504 0.271011819 SUM(D3:D502) 205 D503/500*8 3.28
MONTE CARLO ERROR