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 for the second game. Run the simulation. Is the advantage still for de Mere to win the game? What empirical probability do you get?
rolls <- 24
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 <- c(sample(1:6,1), sample(1:6,1))
# roll two dice
successes <- successes + (outcome[1]==1 & outcome[2]==1)
#is it a Double-Ace?
}
wins <- wins + (successes > 0)
}
Now, open up a text edit window by typing in a linux terminal window:
Here is the more crypic R code using the replicate function:sum(replicate(10000,sum(replicate(24, sample(1:6,1)==1 & sample(1:6,1)==1)) > 0))I got 4921 out ot 10,000; very close to the theoretical value of .4914.