1. What is the probability of rolling a sum of 12 on three rolls of six-sided dice? Express your answer as a decimal number only. Show your R code.

dice_grid <- expand.grid(rep(list(1:6), 3))
dice_grid$sums <- rowSums(dice_grid)
print(length(dice_grid$sums))
## [1] 216
print(sum(dice_grid$sums == 12))
## [1] 25

Out of the total number of outcomes, 216, there are 25 possible combinations that have a sum of 12, so the probability is \(\frac{25}{216} = 0.1157\)

2. A newspaper company classifies its customers by gender and location of residence. The research department has gathered data from a random sample of customers. What is the probability that a customer is male and lives in ‘Other’ or is female and lives in ‘Other’?

customers <- matrix(c(200, 200, 100, 200, 200, 300, 100, 200, 100, 100), nrow = 5, ncol = 2)
total_customers <- sum(customers)
prob_males_other <- (200 + 100)/(total_customers)
print(prob_males_other)
## [1] 0.1764706

The probability that a customer is lives in ‘Other’ (being either male or female) is 0.1765.

3. Two cards are drawn without replacement from a standard deck of 52 playing cards. What is the probability of choosing a diamond for the second card drawn, if the first card, drawn without replacement was a diamond?

num_cards <- 52
num_diamonds <- 13
prob <- (num_diamonds - 1)/(num_cards - 1)
print(prob)
## [1] 0.2352941

After removing a diamond, there would be one less card in the total and in the diamond supply, so the probability would be 0.2353.

4. A coordinator will select 10 songs from a list of 20 songs to compose an event’s musical entertainment lineup. How many different lineups are possible?

library(gtools)
perm_without_replacement <- function(n, r){
  return(factorial(n)/factorial(n - r))
}
perm_without_replacement(20, 10)
## [1] 670442572800

There are 670442572800 different lineups, assuming order matters.

5. You are ordering a new home theater system that consists of a TV, surround sound system, and DVD player. You can choose from 20 different TVs, 20 types of surround sound systems, and 18 types of DVD players. How many different home theater systems can you build?

home_theater_systems <- choose(20,1)*choose(20,1)*choose(18,1)
home_theater_systems
## [1] 7200

Since we are only selecting one of each category, and the order of the selection doesn’t matter, we can consider this a combination using the choose function without replacement.

6. A doctor visits her patients during morning rounds. In how many ways can the doctor visit 10 patients during the morning rounds?

perm_without_replacement(10,10)
## [1] 3628800

This can be treated as a permutation as order would matter. This is equivalent to just doing 10 factorial, to produce 3628800 ways.

7. If a coin is tossed 7 times, and then a standard six-sided die is rolled 3 times, and finally a group of four cards are drawn from a standard deck of 52 cards without replacement, how many different outcomes are possible?

coin_outcomes <- 2^7
die_outcomes <- 6^3
card_outcomes <- perm_without_replacement(52,4)
print(coin_outcomes*die_outcomes*card_outcomes)
## [1] 179640115200

Each group is independent of the other, each coin toss and die roll is independent, so multiplication of the total number of options will account for the coins and dice. The cards can be treated as a permutation without replacement as the order would matter.

8. In how many ways may a party of four women and four men be seated at a round table if the women and men are to occupy alternate seats.

women_options <- factorial(3)
men_options <- factorial(4)
total_options <- women_options*men_options
print(total_options)
## [1] 144

There are 3! ways for the women to be arrange, as the table is circular each offset by one seat would be identical for the women, then once the women are seated, there are 4! ways for the men to be arrange in between them.

9. An opiod urinalysis test is 95% sensitive for a 30-day period, meaning that if a person has actually used opioids within 30 days, they will test positive 95% of the time P(+ | User) = 0.95. The same test is 99% specific, meaning that if they did not use opioids within 30 days, they will test negative P(- | Not User) = 0.99. Assume that 3% of the population are users. Then what is the probability that a person who test positive is actually a user P(User | +)?

pos_given_user <- 0.95
neg_given_nonuser <- 0.99
user <- 0.03
nonuser <- 1 - user
neg_given_user <- 1 - pos_given_user
pos_given_nonuser <- 1 - neg_given_nonuser

pos <- pos_given_nonuser*nonuser + pos_given_user*user

user_given_pos <- (pos_given_user*user)/pos
print(user_given_pos)
## [1] 0.7460733

Using Bayes Theorem the probability that a person who test positive is actually a user is 0.7461.

10. You have a hat in which there are three pancakes. One is golden on both sides, one is brown on both sides, and one is golden on one side and brown on the other. You withdraw one pancake and see that one side is brown. What is the probability that the other side is brown? Explain.

brown_brown <- 1/3
brown_gold <- 1/3
gold_gold <- 1/3

brown_side_given_brown_brown <- 1
brown_side_given_brown_gold <- 1/2

brown_side <- brown_brown*brown_side_given_brown_brown + brown_gold*brown_side_given_brown_gold

brown_brown_given_brown_side <- (brown_side_given_brown_brown*brown_brown)/brown_side
print(brown_brown_given_brown_side)
## [1] 0.6666667

There is a 2/3 chance that the other side is brown. This is shown by Bayes’ theorem above.