What is the probability of rolling a sum of 12 on three roles of six-sided dice?
dice <- expand.grid(die1 = 1:6, die2 = 1:6, die3 = 1:6)
sums <- rowSums(dice)
prob_12 <- length(sums[sums == 12]) / length(sums)
round(prob_12, 4)
## [1] 0.1157
What is the probability that a customer is male and lives in ‘Other or is female and lives in ’Other’?
data <- matrix(c(200, 300,
200, 100,
100, 200,
200, 100,
200, 100),
nrow = 5, byrow = TRUE)
rowSums(data)
## [1] 500 300 300 300 300
colSums(data)
## [1] 900 800
probability <- rowSums(data)[5] / sum(data)
round(probability, 4)
## [1] 0.1765
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?
# 12 diamonds remain out of 51 total cards after removing one diamond
probability <- 12 / 51
round(probability, 4)
## [1] 0.2353
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?
lineups <- choose(20, 10)
lineups
## [1] 184756
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?
systems <- 20 * 20 * 18
systems
## [1] 7200
A doctor visits her patients during morning rounds. In how many ways can the doctor visit 10 patients during the morning rounds?
ways <- factorial(10)
ways
## [1] 3628800
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 <- choose(52, 4)
total_outcomes <- coin_outcomes * die_outcomes * card_outcomes
total_outcomes
## [1] 7485004800
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.
men_arrangements <- factorial(4 - 1)
women_arrangements <- factorial(4)
total_ways <- men_arrangements * women_arrangements
total_ways
## [1] 144
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 | +)?
p_user <- 0.03
p_not_user <- 1 - p_user
p_pos_given_user <- 0.95
p_pos_given_not_user <- 1 - 0.99
p_user_given_pos <- (p_pos_given_user * p_user) /
((p_pos_given_user * p_user) + (p_pos_given_not_user * p_not_user))
round(p_user_given_pos, 4)
## [1] 0.7461
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.
# 3 pancakes, 2 sides each = 6 equally likely sides to be looking at
# Golden-Golden: 0 brown sides
# Brown-Brown: 2 brown sides (both flip to brown)
# Golden-Brown: 1 brown side (flips to golden)
total_brown_sides <- 3
brown_that_flip_to_brown <- 2
prob <- brown_that_flip_to_brown / total_brown_sides
round(prob, 4)
## [1] 0.6667