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
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
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
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
7,200 home theater system you can build.
diff_theater <- 20 * 20 * 18
print(diff_theater)
## [1] 7200
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,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
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
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
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