MATH 335: Fermat and Pascal's other problem

Fermat and Pascal discussed this problem, in addition to the problem of points. The Chevalier de Mere had been winning money by betting even money he could roll an ace (i.e., a "1") within four rolls of a fair die. It turns out that his chance of winning this bet is slightly in his favor (probability = .518). After a while people caught on to being at a disadvantage, so de Mere looked for a different game and came up with this: "I will roll at least one `double-ace' within 24 rolls of a pair of dice." (He used proportional reasoning to come up with the second game, based upon the first game. Do you see how?)

Here is R code to run a simulation. Run the simulation and see if you get confirmatory evidence for the .518 value given above.


rolls <- 4
reps <- 10000  # Usually this will be a large number (e.g. 10000)
wins <- 0  # de Mere's wins; intialize to 0

for (i in 1:reps) {   # begin a loop with index i
         successes <- 0  # de Mere is hoping for at least
                         # one success.
         for (j in 1:rolls) {
             outcome <- sample(1:6,1)  # single die roll
             successes <- successes + (outcome==1) #is it an Ace?
         }
         wins <- wins + (successes > 0)
}

Now, open up a text edit window by typing in a linux terminal window:

gedit FPRCode.txt &

Then cut and paste the R code from above into this file and modify it to run the second of de Mere's games. What empirical probability to you get for his winning?



NOTE: The for function in R is a way to write loops. Pages 40 and 41 of the Introduction to R document discusses loops. One point the document makes is that, especially with larger programs than we have here, loops can run quite slowly in R, so it is better to take what the document calls a `whole object' view. In this case an alternative to the for loop is to use the replicate function. Here is the same procedure coded using replicate .


sum(replicate(10000,sum((replicate(4,sample(1:6,1))==1))>0))