Roulette is a very popular casino game all over the world. Consider a roulette wheel numbered 1-36 and a 0 spot. Calculate the theoretical probability of getting a number in the first 12(1-12) OR a Red. Use a Venn Diagram to help show this probability. You must simulate this probability with 100 trials(rolls). This can be done using a random number generator, and actual roulette wheel or any other random method. Calculate the simulated probability of your 100 trials and compare to the theoretical probability. Make sure to show ALL simulated rolls.
#The numbers that are red and the numbers in the first 12 are listed below
red <- c(1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36)
first12 <- c(1:12)
Libraries used
library(ggvenn)
library(tidyverse)
library(shiny)
library(dplyr)
library(tidyr)
Theoretical Probability is calculated by dividing the number of favorable outcomes by the number of possible outcomes. So for our question of finding the Theoretical Probability of getting a number in the first 12 numbers (1-12) OR a red number, we would have to find the total amount of numbers that are either a red or in the first 12 numbers which was listed as the rf value listed in the section fo code below, then divide that by the total amount of outcomes which is all the numbers from 0 to 36 which is the all value (listed in Topic tab).
rf <- c(1:12,14,16,18,19,21,23,25,27,30,32,34,36)
all <- c(0:36)
\[ Theoretical Probability = length(rf)/length(all) \]
Now to find all that needs to be done is to divide the length of the 2 values and then we get the Theoretical Probability.
tp <- length(rf)/length(all)
tp
## [1] 0.6486486
The Theoretical Probability comes out to be around 64.86%.
Displaying the probability on a Venn diagram.
TD <- list("All Other Numbers"= all, 'Red or First 12' = c(rf))
ggvenn(TD,c("All Other Numbers","Red or First 12"), show_percentage = T,show_elements = F, text_size = 4, set_name_size = 4, fill_color = c("yellow","red"), digits = 2)
The Venn diagram shows the Theoretical Probability of the numbers that are either Red or First 12 and the percentage of the cross zone in the diagram is 64.86% which is the same as the Theoretical Probability calculated above.
To simulate the probability we can take 100 random numbers and then find the probability of the reds or first 12 numbers out of the rest of the outcomes
rand <- data.frame(Outcomes = (sort(sample(0:36, 100, replace=T))))
rand
## Outcomes
## 1 0
## 2 0
## 3 0
## 4 1
## 5 1
## 6 1
## 7 1
## 8 2
## 9 2
## 10 2
## 11 3
## 12 3
## 13 4
## 14 4
## 15 4
## 16 4
## 17 4
## 18 5
## 19 6
## 20 6
## 21 6
## 22 7
## 23 9
## 24 9
## 25 9
## 26 9
## 27 10
## 28 10
## 29 10
## 30 10
## 31 10
## 32 11
## 33 12
## 34 12
## 35 12
## 36 13
## 37 13
## 38 13
## 39 14
## 40 14
## 41 16
## 42 16
## 43 16
## 44 17
## 45 17
## 46 17
## 47 17
## 48 17
## 49 19
## 50 19
## 51 19
## 52 19
## 53 20
## 54 21
## 55 21
## 56 22
## 57 22
## 58 22
## 59 23
## 60 23
## 61 23
## 62 23
## 63 24
## 64 25
## 65 25
## 66 26
## 67 26
## 68 27
## 69 27
## 70 28
## 71 28
## 72 28
## 73 28
## 74 28
## 75 29
## 76 29
## 77 30
## 78 31
## 79 31
## 80 31
## 81 31
## 82 31
## 83 31
## 84 31
## 85 32
## 86 32
## 87 32
## 88 32
## 89 33
## 90 33
## 91 33
## 92 34
## 93 34
## 94 34
## 95 34
## 96 35
## 97 36
## 98 36
## 99 36
## 100 36
table(rand)
## rand
## 0 1 2 3 4 5 6 7 9 10 11 12 13 14 16 17 19 20 21 22 23 24 25 26 27 28
## 3 4 3 2 5 1 3 1 4 5 1 3 3 2 3 5 4 1 2 3 4 1 2 2 2 5
## 29 30 31 32 33 34 35 36
## 2 1 7 4 3 4 1 4
Finding the simulated probability
rdfilter <- subset(rand, Outcomes %in% c(rf))
sp <- nrow(rdfilter)/nrow(rand)
sp
## [1] 0.64
To compare the Theoretical and the Simulated Probabilities, we have to find the difference between them.
rp<-tp-sp
rp
## [1] 0.008648649
We can conclude that from this that the Theoretical Probability is pretty accurate at finding the probability of getting a red or a number in the first 12 numbers, as the difference is not that large