static model simulation monte carlo simulation examples
play

Static Model Simulation - Monte Carlo Simulation Examples Examples - PowerPoint PPT Presentation

Static Model Simulation - Monte Carlo Simulation Examples Examples 1 Coin-tossing experiment. Toss the coin for 1 million times and note down the outcomes. 1 2 Rolling-die experiment. Roll the die for 1 million times and note down the


  1. Static Model Simulation - Monte Carlo Simulation — Examples Examples 1 Coin-tossing experiment. Toss the coin for 1 million times and note down the outcomes. 1 2 Rolling-die experiment. Roll the die for 1 million times and note down the outcomes. 1 3 Simulate π . 4 Evaluate the definite integral � b g ( x ) dx . a 5 Coin-tossing problem. 6 Birthday and nearly birthday problems. 7 Lottery problem. R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 28 / 46 Introduction to Discrete SimulationIntroduction

  2. Evaluating definite integral Example ( · · · ) Let � b I = g ( x ) dx . a Let X = U [ a , b ] and Y = ( b − a ) g ( X ). E [ Y ] = E [( b − a ) g ( X )] = ( b − a ) E [ g ( X )] � b = ( b − a ) g ( x ) f X ( x ) dx a � b 1 = ( b − a ) g ( x ) b − adx a � b = g ( x ) dx = I . a R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 29 / 46 Introduction to Discrete SimulationIntroduction

  3. Evaluating definite integral · · · Example ( · · · ) Algorithm: 1 Set sum = 0 and count = 0. 2 while ( count < = n ) Generate r from U [ a , b ] Compute: y = ( b − a ) g ( r ) sum = sum + y count = count + 1 endwhile sum 3 I ≈ counter R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 30 / 46 Introduction to Discrete SimulationIntroduction

  4. Coin-tossing problem Example Two players A and B throw a fair coin N times. If Head, then A gets 1 point; otherwise B. ◮ What is the probability that one of the players is leading between 50% and 55% of the time? Or more than 95% of the time? ◮ In case of 20 trials, say, what is the probability of 5 Heads in a row? R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 31 / 46 Introduction to Discrete SimulationIntroduction

  5. Coin-tossing problem · · · Example ( · · · ) Let P ( α, β ) be the probability that one of the players is leading between 100 α % and 100 β % of the time, where 0 ≤ α < β ≤ 1. To determine P ( α, β ) do the following: Repeat the experiment of 1 “Throwing N times with a coin” many times. An experiment is successful if one of the players is leading between 2 100 α % and 100 β % of the time. Then 3 P ( α, β ) = # successful experiments total # experiments R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 32 / 46 Introduction to Discrete SimulationIntroduction

  6. Coin-tossing problem · · · – Pseudo code for M experiments Example ( · · · ) Variables time A and time B denote, respectively, the number of times player A leads player B and player B leads player A : success = 0 ; for run = 1 to M do invoke the subprogram coin tossing which returns time A and time B ; if ( α < time A < β ) or ( α < time B < β ) N N success = success +1 ; endif endfor success Print M R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 33 / 46 Introduction to Discrete SimulationIntroduction

  7. Coin-tossing problem · · · – Pseudo code for subprogram coin tossing Example ( · · · ) n = 0 ; points A = 0 ; points B = 0 ; time A = 0 ; while ( n < N ) do if ( random < 0 . 5) points A = points A + 1 ; else points B = points B + 1 ; endif if ( points A − points B > 0) time A = time A + 1 ; endif n = n + 1 ; endwhile time B = N − time A ; return time A and time B ; R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 34 / 46 Introduction to Discrete SimulationIntroduction

  8. Coin-tossing problem · · · Example ( · · · ) ( α, β ) P ( α, β ) (0 . 5 , 0 . 55) 0.06 (0 . 5 , 0 . 6) 0.12 (0 . 9 , 1 . 0) 0.40 (0 . 95 , 1 . 0) 0.28 (0 . 98 , 1 . 0) 0.16 R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 35 / 46 Introduction to Discrete SimulationIntroduction

  9. Coin-tossing problem · · · Example ( · · · ) Two players A and B throw a fair coin N times. If Head, then A gets 1 point; otherwise B gets 1 point. ◮ What is the probability that one of the players is leading between 50% and 55% of the time? ◮ What is the probability that one of the players is leading 95% of the time? ◮ In case of 20 trials, say, what is the probability of 5 Heads in row? R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 36 / 46 Introduction to Discrete SimulationIntroduction

  10. Coin-tossing problem · · · Example ( · · · ) Let P ( k ) be the probability of at least k successive Heads in case of 20 trials. To determine P ( k ) do the following: ◮ Repeat the experiment “Throw 20 times with a coin” many times ◮ An experiment is successful if a row of at least k heads appears. Then P ( k ) = number of successful experiments total number of experiments R.B. Lenin (rblenin@daiict.ac.in) () Autumn 2007 37 / 46 Introduction to Discrete SimulationIntroduction

Recommend


More recommend