Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#setting the number of simulations of the roulette game we want to run

n <- 10000

#P(red) = 18/38

#38 roll game, need >= 20 red to win


#expected value of times it lands on red
mean(rbinom(n, 38, 18/38))
#returns the mean of wins, prob. of winning the game
mean(rbinom(n, 38, 18/38) >= 20)

#76 roll game, need >= 40 red red to win


#expected value of times it lands on red
mean(rbinom(n, 76, 18/38))
#returns the mean of wins, prob. of winning the game
mean(rbinom(n, 76, 18/38) >= 40)

#1
sample(1:6, size=2,replace=T)

#2
sample(1:6,size=8,replace=T)

#3
sample(1:6, 1, prob=c(1,1,1,1,1,2)/7)

#4
sample(1:12, 20, replace=TRUE)

You might also like