B |
|
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 |
In tossing a die a 6 can occur one way out of six ways,
hence P=1/6.
Algorithm: Determine N Set Six = 0 LOOP from i=0 to N Generate a random number R from a uniform distribution Set Dice = 1 + INT(6*R) Check if Dice=6 THEN Increment Six by 1 END IF END LOOP OUTPUT N, Six, Six/N |
Output: N Six Six/N ------------- -------- --------- 10 3 0.3000000 100 19 0.1900000 1,000 186 0.1860000 10,000 1659 0.1659000 100,000 16748 0.1674800 1,000,000 166705 0.1667050 10,000,000 1667210 0.1667210 100,000,000 16666290 0.1666629 1,000,000,000 166672853 0.1666728 |