## Example

Chapter 1.2: Discrete Probability Distribution

Question 6, Page 35

A die is loaded in such a way that the probability of each face turning up is proportional to the number of dots on that face. (For example, a six is three times as probable as a two.) What is the probability of getting an even number in one throw?

#### Step 1:

Create a list called die_items to represent all the possible outcomes of rolling the die.

#### Step 2:

Create an empty list called die_probabilities that correspond to the probabilities of each outcome.

#### Step 3:

Write a function to calculate die_probabilities for each component die_items.

If each probability is proportional to the die value, the numerator of each probability will be the die value. The denominator of each probability will be the sum of all possible die values (1 + 2 + 3 + 4 + 5 + 6 = 21)

#### Step 4:

Ensure that all probabilities add up to 1.

#### Step 5:

Sum the probabilities for all even die values.

die_items <- list(1:6)
die_probabilities  <- list()

for (i in die_items){
print(paste0("Die Result: ", i))
probability <- (i * (1/21))
print(paste0("Probability: ", probability, " or ", i, "/21"))
die_probabilities = append(probability, die_probabilities)}
## [1] "Die Result: 1" "Die Result: 2" "Die Result: 3" "Die Result: 4"
## [5] "Die Result: 5" "Die Result: 6"
## [1] "Probability: 0.0476190476190476 or 1/21"
## [2] "Probability: 0.0952380952380952 or 2/21"
## [3] "Probability: 0.142857142857143 or 3/21"
## [4] "Probability: 0.19047619047619 or 4/21"
## [5] "Probability: 0.238095238095238 or 5/21"
## [6] "Probability: 0.285714285714286 or 6/21"
print(paste0("Sum of all probabilities: ", Reduce("+", die_probabilities)))
## [1] "Sum of all probabilities: 1"

$P(Die = 1): \frac{1}{21}$

$P(Die = 2): \frac{2}{21}$

$P(Die = 3): \frac{3}{21}$

$P(Die = 4): \frac{4}{21}$

$P(Die = 5): \frac{5}{21}$

$P(Die = 6): \frac{6}{21}$

$P(even) = P(Die = 2) + P(Die = 4) + P(Die = 6)$

$P(Die is even) = \frac{2}{21} + \frac{4}{21} + \frac{6}{21}$

$P(Die is even) = \frac{12}{21} = \frac{4}{7}$