Matt Morris
August 31, 2015
For the dice thrower (shooter) the object of the game is to throw a 7 or an 11 on the first roll (a win) and avoid throwing a 2, 3 or 12 (a loss). If none of these numbers (2, 3, 7, 11 or 12) is thrown on the first throw (the Come-out roll) then a Point is established (the point is the number rolled) against which the shooter plays. The shooter continues to throw until one of two numbers is thrown, the Point number or a Seven. If the shooter rolls the Point before rolling a Seven he/she wins, however if the shooter throws a Seven before rolling the Point he/she loses.
set.seed(888)#I'm just doing this so replications will produce same resuls
#just settting up a vector to be filled as we go
wins <- rep(0, 1000)
for(i in 1:1000){
# simulate a Come-out rollif shooter wins on Come-out,
wins[i] <- 1
}
makepoint <- function(point){
made <- NA
while(is.na(made)){
roll <- sum(sample(6, 2, replace=T))
if(roll == point){
made <- TRUE
} else if(roll == 7){
made <- FALSE
}
}
return(made)
}
sum(wins)
## [1] 1000
simulating_craps <- function () {
roll <- sum(sample(6,2,replace=T))
if(roll==7 || roll==11)
win <- T
else if(roll==2 || roll==3 || roll==12)
win <- F else
win <- makepoint(roll)
return(win)
}
n_sim <- 1000
wins <- 0
for(i in 1:n_sim)
wins <- wins + simulating_craps()
print(wins/n_sim)
## [1] 0.486
n_sim <- c(3, 9, 27, 81);
th <- seq(0, 1, length=200);
lik <- matrix(NA, 200, length(n_sim));
for (i in seq(along=n_sim))
{
wins <- 0
for(j in 1:n_sim[i])
wins <- wins + simulating_craps()
lik[,i] <- dbinom(wins, n_sim[i],th)
lik[,i] <- lik[,i]/max(lik[,i])
}
matplot(th, lik[,4], type="l", col=1, lty=1,
xlab=expression(theta), ylab="likelihood", main="Likelihoods - 81 simulations")