Is Roulette the Best Way to Make Money?
Simulation of a French Roulette
Image credit: Macau Photo Agency
Load library
library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1 ✔ purrr 0.3.3
## ✔ tibble 2.1.3 ✔ dplyr 0.8.3
## ✔ tidyr 1.0.0 ✔ stringr 1.4.0
## ✔ readr 1.3.1 ✔ forcats 0.4.0
## ── Conflicts ───────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(kableExtra)
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
- A French roulette has:
- 37 colored and numbered pockets on the wheel.
- 0 is green.
- In number ranges from 1 to 10 and 19 to 28:
- Odd numbers are red.
- Even numbers are black.
- In ranges from 11 to 18 and 29 to 36:
- Odd numbers are black.
- Even numbers are red.
wheel = read.csv("https://nkha149.github.io/stat385-sp2020/files/data/roulette.csv")
wheel = as_tibble(wheel)
kable(wheel) %>%
kable_styling(bootstrap_options = "striped", full_width = FALSE)
| number | color |
|---|---|
| 0 | green |
| 1 | red |
| 2 | black |
| 3 | red |
| 4 | black |
| 5 | red |
| 6 | black |
| 7 | red |
| 8 | black |
| 9 | red |
| 10 | black |
| 11 | black |
| 12 | red |
| 13 | black |
| 14 | red |
| 15 | black |
| 16 | red |
| 17 | black |
| 18 | red |
| 19 | red |
| 20 | black |
| 21 | red |
| 22 | black |
| 23 | red |
| 24 | black |
| 25 | red |
| 26 | black |
| 27 | red |
| 28 | black |
| 29 | black |
| 30 | red |
| 31 | black |
| 32 | red |
| 33 | black |
| 34 | red |
| 35 | black |
| 36 | red |
- We will write an R function named
roulette()that simulate a roulette, that is it has:- Input: 2 arguments
betandamountbet: argument that takes one of the following options:low(1-18) orhigh(19-36): A bet that the number will be in the chosen range.redorblack: A bet that the number will be the chosen color.evenorodd: A bet that the number will be of the chosen type.firstorsecondorthird: A bet that the number will be in the chosen dozen: first (1-12), second (13-24), or third (25-36).- any number from 0 to 36.
amount: amount in dollars that you want to bet on. The default value foramountis1.
- Output:
- The amount of money you gain/lose after the bet.
-amountif you lose the bet.- The amount of money win is calculated following the table below.
- Make sure to include the
$dollar sign.
- The amount of money you gain/lose after the bet.
- Input: 2 arguments
| Bet Name | Winning spaces | Payout |
|---|---|---|
| Straight up (a single number) | Any single number | 36 to 1 |
| Low (1 to 18) | 1, 2, 3, …, 18 | 1 to 1 |
| High (19 to 36) | 19, 20, 21, …, 36 | 1 to 1 |
| Red | 1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36 | 1 to 1 |
| Black | 2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35 | 1 to 1 |
| Odd | 1, 3, 5, …, 35 | 1 to 1 |
| Even | 2, 4, 6, …, 36 | 1 to 1 |
| 1st dozen | 1 through 12 | 2 to 1 |
| 2nd dozen | 13 through 24 | 2 to 1 |
| 3rd dozen | 25 through 36 | 2 to 1 |
Simulations and Graphing
roulette = function(bet, amount = 1) {
pick = sample(x = 0:(nrow(wheel) - 1), size = 1, replace = TRUE)
low = 1:18
high = 19:36
red = c(1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36)
odd = seq(from = 1, to = 36, by = 2)
black = c(2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35)
even = seq(from = 2, to = 36, by = 2)
first = 1:12
second = 13:24
third = 25:36
if ((pick %in% low) & (bet == "low")) {
amount
} else if ((pick %in% high) & (bet == "high")) {
amount
} else if ((bet == "red") & (pick %in% red)) {
amount
} else if ((bet == "black") & (pick %in% black)) {
amount
} else if ((bet == "even") & (pick %in% even)) {
amount
} else if ((bet == "odd") & (pick %in% odd)) {
amount
} else if ((bet == "first") & (pick %in% first)) {
amount * 2
} else if ((bet == "second") & (pick %in% second)) {
amount * 2
} else if ((bet == "third") & (pick %in% third)) {
amount * 2
} else if (pick == bet) {
amount * 36
} else {
amount * -1
}
}
- We want to estimate the probability of winning if we keep betting on
red. To do that, we use simulation studies, that is running theroulette()function many many times and record the number of times we win (not have a negative total amount at the end of the game). The number of simulationsnis 5000.
set.seed(385)
results = replicate(roulette(bet = "red", amount = 1), n = 5000)
length(results[results == 1]) / 5000 # probability of winning if we keep betting on red
## [1] 0.4862
- Similarly, we want estimate the probability of winning if we keep betting on the
firstdozen. The number of simulationsnis 5000.
set.seed(385)
results2= replicate(roulette(bet = "first"), n = 5000)
length(results2[results2 == 2]) / 5000 # probability of winning if we keep betting on the first dozen
## [1] 0.3114
- Now, we want to estimate the expected value of amount of money we will have by the end of the game if we bet on
redwith $1. We will do the simulations for 10000 times wheren= 10,000.
set.seed(385)
results3 = replicate(roulette(bet = "red", amount = 1), n = 10000)
1 * length(results3[results3 == 1]) / 10000 - 1 * (1 - length(results3[results3 == 1]) / 10000) # expected value of amount of money we will have by the end of the game if we bet on odd with $5
## [1] -0.0248
Interpretation of Results
It helps to remember the meaning of expected value to interpret the results of this calculation. The expected value is basically, a measurement of the average. It indicates what will happen in the long run every time that we bet $1 on red.
While we might win several times in a row in the short term, in the long run, we will lose over 2 cents on average each time that we play. The presence of the 0 and 00 spaces are just enough to give the house a slight advantage. This advantage is so small that it can be difficult to detect, but in the end, the player always loses