Round after 4 digits.
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.
Hint: use expand.grid. rowSums, and length functions.
#TOTAL NO. OF POSSIBILITIES WHEN ROLLING DICE 3x
total_options <- expand.grid(rep(list(1:6), 3))
#ALL SUMS FOR THE THREE POSSIBLE ROLLS
total_sums <- rowSums(total_options)
#NUMERATOR
equals_12 <- sum(total_sums == 12)
#DENOMINATOR
total_probability <- length(total_sums)
#NO. OF SUCCESS TRIALS/TOTAL POSSIBILITIES
probability_of_3rolls_equaling_12 <- equals_12 / total_probability #probability
print(probability_of_3rolls_equaling_12)
## [1] 0.1157407
0.1157
A newspaper company classifies its customers by gender and location
of residence. The research department has gathered data from a random
sample of customers. The data is summarized in the table below. What is
the probability that a customer is male and lives in ‘Other’ or is
female and lives in ‘Other’? Express your answer as a decimal number
only. Show your R code.
Hint: create the matrix above in R, use rowSums and col.Sums to generate marginal probabilities.
gender_residence <- data.frame(
Residence = c("Apartment", "Dorm", "With Parent(s)", "Sorority/Fraternity House", "Other"),
Males = c(200, 200, 100, 200, 200),
Females = c(300, 100, 200, 100, 100))
filter_by_Other <- gender_residence[gender_residence$Residence == "Other", ]
male_other <- filter_by_Other[, c("Males")]
female_other <- filter_by_Other[, c("Females")]
probability_male_other <- sum(male_other)
probability_female_other <- sum(female_other)
total_customers <- sum(gender_residence$Males, gender_residence$Females)
print(probability_male_other / total_customers)
## [1] 0.1176471
print(probability_female_other / total_customers)
## [1] 0.05882353
Males and other: 0.1176
Females and other: 0.0588
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? Express your answer as a decimal number only. Show your R code.
total_number_diamonds <- 13
total_cards_deck <- 52
#first card drawn
first_card_probability <- total_number_diamonds/total_cards_deck
#second card drawn
second_card_probability <- (total_number_diamonds - 1)/(total_cards_deck - 1)
print(first_card_probability*second_card_probability)
## [1] 0.05882353
0.0588
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? Show your R code.
#ASSUMING ORDER DOESN'T MATTER, WITHOUT REPETITON (permutation)
#revised 4/03/24
choose(n=20, k=10) * factorial(10)
## [1] 670442572800
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? Show your R code.
#ORDER DOESN'T MATTER, WITH REPETITION
home_system <- data.frame(
TV = 20,
Surround_Sound_System = 20,
DVD_player = 18)
total_homesystem_combos <-
home_system$TV * home_system$Surround_Sound_System * home_system$DVD_player
print(total_homesystem_combos)
## [1] 7200
7200
A doctor visits her patients during morning rounds. In how many ways can the doctor visit 10 patients during the morning rounds? Show your R code.
#Permutation, without replacement
patients <- 10
total_ways <- factorial(patients)
print(total_ways)
## [1] 3628800
3,628,800
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? Show your R code.
#combination
coin <- 2
die <- 6
deck <- 52
total_combos <-
(coin)^7 *
(die)^3 *
choose(52,4)
total_combos
## [1] 7485004800
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. Show your R code.
women <- 4
males <- 4
total_options_women <- factorial(women - 1)
total_options_males <- factorial(males)
print(total_options_women * total_options_males)
## [1] 144
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(A \mid B)\ = \frac{ P(B \mid A)\ * P(A)}{P(B)}\]
\[P(User \mid +)\ = \frac{ 0.30 * 0.95 } {(0.95*0.03)+(0.01*0.97)}\]
Prob_user_positive <- (0.03 * 0.95)/((0.95*0.03)+(0.01*0.97))
print(Prob_user_positive)
## [1] 0.7460733
0.7461 (75%)
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.
number_of_golden_side <- 2
probability <- 1/3
print(probability*number_of_golden_side)
## [1] 0.6666667
0.6667 (67%). Here we are trying to find the probability that the second side of the pancake is also brown. The chance of getting any pancake from a hat is 1/3, and there are two opportunities for the second side of the pancake to be brown.