B prev next
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

<< MC APPLICATIONS >>

Tossing A Coin

A coin is tossed 6 times. Calculate probability of getting:

  (a)   exactly four heads
  (b)   at least four heads

Exact results:
(a)  
(b)  

where  


Algorithm:

 Determine N  (# of experiment)
 Set E4H  = 0 (Exacly 4 Head)
 Set AL4H = 0 (At Least 4 Heads)

 LOOP1 from i=0 to N

   Set Head = 0
   LOO2 k=1,6
        Generate a random number R 
        from a uniform distribution
        Check IF R<0.5 THEN 
          Increment Head by 1
        END IF
   END LOO2

   Check IF Head =4 Increment E4H by 1
   Check IF Head>=4 Increment AL4H by 1

 END LOOP1 

 OUTPUT N, E4H/N, AL4H/N

Output:

      N            (a)        (b)
 -------------  ---------  ---------
            10  0.1000000  0.3000000
           100  0.3400000  0.4600000
         1,000  0.2360000  0.3380000
        10,000  0.2342000  0.3393000
       100,000  0.2328500  0.3430800
     1,000,000  0.2346350  0.3438360
    10,000,000  0.2343817  0.3434362
   100,000,000  0.2343522  0.3437505
 1,000,000,000  0.2343743  0.3437576


The computer implementations of the algorithm : coin6.f90 | coin6.c