In: Statistics and Probability
You are playing a version of the roulette game, where the pockets are from 0 to 10 and even numbers are red and odd numbers are black (0 is green). You spin 3 times and add up the values you see. What is the probability that you get a total of 15 given on the first spin you spin a 2? What about a 3?
Solve by simulation and analytically.
R-Script :
set.seed(1729)
prob<-c()
for (i in 1:1000) {
first<-sample(c(0:10), 1000, replace = T)
second<-sample(c(0:10), 1000, replace = T)
third<-sample(c(0:10), 1000, replace = T)
totalsum<-first+second+third
df<-data.frame(first, second, third, totalsum)
count2<-sum(df$first==2 & df$totalsum==15)
prob[i]<-count2/1000
}
mean(prob)
Output : 0.006055