set.seed(123)
roulette <- function(spin, bet){
r <- c(1, 3, 5, 7, 9, 12, 14, 16, 18, 21, 23, 25, 27, 28, 30, 32, 34, 36)
b <- c(2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 29, 31, 33, 35)
g <- c(37, 38)
wins <- 0
record <- 0
spins <- sample(1:38, spin, replace = TRUE)
record <- spins %in% r
wins <- sum(record, na.rm = TRUE)
wins <- (2 * wins) - (spin - wins)
return(wins)
}
My gambling is a little rusty, but I assume that “If you bet $1, you win $1” really means you have a net of $2 for a victory. Otherwise you lose whatever you bet. So let’s run a few simulations and see what our profits (if any) are.
try1 <- roulette(1000, 1)
try2 <- roulette(1000, 1)
try3 <- roulette(1000, 1)
try1
## [1] 401
try2
## [1] 425
try3
## [1] 371
We see that the winnings are roughly consistent across multiple attempts.