1. What is the probability of rolling a sum of 12 on three rolls of six-sided dice?

11.57% of rolling a sum of 12 on three rolls of six-sided dice.

dice_rolls <- expand.grid(1:6, 1:6, 1:6)
sums <- rowSums(dice_rolls)
sum_12 <- sum(sums == 12)
total_combinations <- length(sums)

p_S12 <- sum_12 / total_combinations

print(p_S12, 4)
## [1] 0.1157

2. What is the probability that a customer is male and lives in ‘Other’ or is female and lives in ‘Other’?

17.65% of probability that a customer is male and lives in ‘Other’ OR is female and lives in ‘Other’.

# Creating a matrix 
customer_data <- matrix(c(200, 200, 100, 200, 200, 
                          300, 100, 200, 100, 100), 
                        nrow = 2, 
                        byrow = TRUE, 
                        dimnames = list(c("Male", "Female"), 
                                        c("Apartment", "Dorm", "With Parents", 
                                          "Sorority/Fraternity", "Other")))

total_customers <- sum(customer_data)

male_other <- customer_data["Male", "Other"] / total_customers
female_other <- customer_data["Female", "Other"] / total_customers

# Combined probability for the OR problem
p_MorF_in_other <- male_other + female_other

print(customer_data)
##        Apartment Dorm With Parents Sorority/Fraternity Other
## Male         200  200          100                 200   200
## Female       300  100          200                 100   100
print(p_MorF_in_other, 4)
## [1] 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 firstcard, drawn without replacement, was a diamond?

23.53% of probability of choosing a diamond for the second card drawn, if the first card, drawn without replacement, was a diamond.

r_diamonds <- 13-1
r_cards <- 52-1

p_RD <- r_diamonds / r_cards

print(p_RD, 4)
## [1] 0.2353

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

Combination with NO repeats allowed problem, as the coordinator must select 10 different songs but orders won’t matter in this scenrio. 184,756 different lineups possible.

combination_no_repeats <- function(n, r) {
  return(factorial(n) / (factorial(r) * factorial(n - r)))
}

n <- 20 
r <- 10 
lineups <- combination_no_repeats(n, r)

print(lineups)
## [1] 184756

or we can use the choose function to solve this problem.

choose(20, 10)
## [1] 184756

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

7,200 home theater system you can build.

diff_theater <- 20 * 20 * 18
print(diff_theater)
## [1] 7200

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

This is a permutation problem because the order would matter in terms of how the doctor visits the patient. 3,628,800 ways of the doctor visit 10 patients during the morning rounds.

doctor_visit <- factorial(10)
print(doctor_visit)
## [1] 3628800

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?

7,485,004,800 different outcomes possible.

coin_outcomes <- 2^7
dice_outcomes <- 6^3
# combination with NO repeats because orders don't matter but no replacements in this case
card_outcomes <- choose(52, 4)

total_outcomes <- coin_outcomes * dice_outcomes * card_outcomes
print(total_outcomes)
## [1] 7485004800

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.

Permutation problem. And because they need to be in alternate seating, we must have one person (can be either gender) to be set in one seat and the rest of them being placed afterwards to determine the final seating, so either men or women needs to be in factorial of 3 instead of 4. Hence, 144 ways of seating arrangement.

women <- factorial(4)
men <- factorial(3)

arrangements <- women * men
print(arrangements)
## [1] 144

9. An opioid 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) =.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) = .99. Assume that 3% of the population are users. Then what is the probability that a person who tests positive is actually a user P(User | +)?

Using Bayes Theorem to solve this problem, as we get 74.61% of probability that a person who tests positive is actually a user P(User | +).

# Given and simple calculated probabilities
p_user <- 0.03
p_not_user <- 1 - p_user
p_positive_given_user <- 0.95
p_positive_given_not_user <- 1 - 0.99
p_positive <- (p_positive_given_user * p_user) + (p_positive_given_not_user * p_not_user)

# P(User | +)
p_user_given_positive <- (p_positive_given_user * p_user) / p_positive
print(p_user_given_positive, 4)
## [1] 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?

Conditional probability to solve this problem, as we get 66.67% of probability that the other side is brown after we first see the one side is brown.

p_brown_and_brown <- 1/3 
p_brown <- (1/3)*0 + (1/3)*1 + (1/3)*(1/2)


# Probability of brown given brown
p_b_given_b <-p_brown_and_brown / p_brown
print(p_b_given_b, 4)
## [1] 0.6667