- A box contains 54 red marbles, 9 white marbles, and 75 blue marbles. If a marble is randomly selected from the box, what is the probability that is red or blue? Express your answer as a fraction or a decimal number rounded to four decimal places.
p_red <- 54 / (54 + 9 + 75)
p_white <- 9 / (54 + 9 + 75)
p_blue <- 75 / (54 + 9 + 75)
# The probability that the marble is red or blue
p_red_or_blue <- round(p_red + p_blue, 4)
p_red_or_blue
## [1] 0.9348
- You are going to play mini golf. A ball machine that contains 19 green golf balls, 20 red golf balls, 24 blue golf balls, and 17 yellow golf balls, randomly gives you your ball. What is the probability that you end up with a red golf ball? Express your answer as a simplified fraction or a decimal rounded to four decimal places.
# The probability of ending up with a red golf ball
p_red <- 20 / (19 + 20 + 24 + 17)
round(p_red, 4)
## [1] 0.25
A pizza delivery company classifies its customers by gender and location of residence. The research department has gathered data from a random sample of 1399 customers. The data is summarized in the table below.
What is the probability that a customer is not male or does not live with parents? Write your answer as a fraction or a decimal number rounded to four decimal places.
Being male and living with your parents are not mutually exclusive events, but they are independent. Thus the probability of being one or the other is
\(P(\text{A or B}) = (\ p(A) + p(B)\ ) - (\ p(A) \times p(B)\ ).\)
total_n <- 81 + 116 + 215 + 130 + 129 + 228 + 79 + 252 + 97 + 72
p_not_male <- (228 + 79 + 252 + 97 + 72) / total_n
p_not_parents <- (total_n - (215 + 252)) / total_n
p_both <- p_not_male + p_not_parents - (p_not_male * p_not_parents)
round(p_both, 4)
## [1] 0.8399
Determine if the following events are independent:
Going to the gym. Losing weight.
(A) DEPENDENT.
Going to the gym does not guarantee that you lose weight, but it does increase the probability that you will. Similarly, you can be losing weight in other ways than exercising, but it does increase the likelihood that you attend a gym. Since the two probabilities affect one another, the events are not independent.
- A veggie wrap at City Subs is composed of 3 different vegetables and 3 different condiments wrapped up in a tortilla. If there are 8 vegetables, 7 condiments, and 3 types of tortilla available, how many different veggie wraps can be made?
# Find the possible combinations of n materials in k available slots
combos <- function(n, k){
c <- factorial(n) / (factorial(n-k) * factorial(k))
}
# Find the different ways the wraps can be made
combos(8, 3) * combos(7, 3) * combos(3, 1)
## [1] 5880
# This could also have been accomplished using the "choose" function
Determine if the following events are independent:
Jeff runs out of gas on the way to work. Liz watches the evening news.
(B) INDEPENDENT.
Jeff running out of gas does not impact whether Liz watches the evening news (unless perhaps she watches the news to see if he ran out of gas). Similarly, Liz watching the evening news does not impact the probability of Jeff running out of gas. The two probabilities do not affect one another, so the events are independent.
- The newly elected president needs to decide the remaining 8 spots available in the cabinet he/she is appointing. If there are 14 eligible candidates for these positions (where rank matters), how many different ways can the members of the cabinet be appointed?
factorial(14) / factorial(14 - 8)
## [1] 121080960
- A bag contains 9 red, 4 orange, and 9 green jellybeans. What is the probability of reaching into the bag and randomly withdrawing 4 jellybeans such that the number of red ones is 0, the number of orange ones is 1, and the number of green ones is 3? Write your answer as a fraction or a decimal number rounded to four decimal places.
# All possible bean combinations for 4 slots
c_any <- choose((9 + 4 + 9), 4)
# Number of red jellybean combos for 0 slots
c_red <- choose(9, 0)
# Number of orange jellybean combos for 1 slot
c_orange <- choose(4, 1)
# Number of green jellybean combos for 3 slots
c_green <- choose(9, 3)
# Possible combinations of the specific 4 beans
c_combined <- c_red * c_orange * c_green
# Probability of drawing the specific combination from all possible
round(c_combined / c_any, 4)
## [1] 0.0459
- Evaluate the following expression:
\[\frac{11!}{7!}\]
factorial(11) / factorial(7)
## [1] 7920
- Describe the complement of the given event: 67% of subscribers to a fitness magazine are over the age of 34.
The complement is that 33% of subscribers are below the age of 34.
- If you throw exactly three heads in four tosses of a coin, you win $97. If not, you pay me $30.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
The expected value is $1.75 for one game.
prob_win <- choose(4,3) / 2^4
prob_loss <- 1-prob_win
ev <- (prob_win * 97) + (prob_loss * -30)
ev
## [1] 1.75
Step 2. If you played this game 559 times, how much would you expect to win or lose? (Losses must be entered as negative.)
On average, I can expect to win $978.25.
ev * 559
## [1] 978.25
- Flip a coin 9 times. If you get 4 tails or less, I will pay or $23. Otherwise you pay me $26.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
The expected value of one game is a negative – -$1.50.
prob_win <- pbinom(4, size = 9, prob = 0.5)
prob_loss <- 1-prob_win
ev <- (prob_win * 23) + (prob_loss * -26)
ev
## [1] -1.5
Step 2. If you played this game 994 times, how much would you expect to win or lose? (Losses must be entered as negative.)
After 994 games, you will lose (on average) -$1,491.00.
ev * 994
## [1] -1491
- The sensitivity and specificity of the polygraph has been a subject of study and debate for years. A 2001 study of the use of polygraph for screening purposes suggested that the probability of detecting a liar was \(.59\) (sensitivity) and the probability of detecting a “truth telling” was \(.90\) (specificity). We estimate that about 20% of individuals selected for the screening polygraph wil lie.
a. What is the probability that an individual is actually a liar given that the polygraph detected him/her as such?
Set up variables:
# 20% of individuals will lie in the polygraph
ind_lie <- 0.2 # P(A)
ind_truth <- 0.8
# The polygraph detects truth 90% of the time
p_detect_truth <- 0.9
p_fail_detect_truth <- 0.1
# The polygraph detects lies 59% of the time
p_detect_lie <- 0.59
p_fail_detect_lie <- 0.41
The conditional probability of two events \(A\) and \(B\) can be found using Bayes’ Theorem.
\[ P\ (A\ |\ B) = \frac{P(B\ |\ A) \times P(A)}{P(B)} \]
The probability that an individual is a liar, given the polygraph detects a liar, is 0.1192.
# A = An individual is a real liar
# B = The polygraph detects a liar
# P(B): The probability of the polygraph detecting a real liar
p_b_lie <- (ind_truth * p_fail_detect_truth) + (ind_lie * p_detect_lie)
# P(B|A): The probability that given a real liar, the polygraph detects it
p_ba_lie <- ind_lie * p_detect_lie
# P(A|B): The probability that that given the polygraph detecting a liar, the individual is really a liar
p_ab_lie <- (p_ba_lie * ind_lie) / p_b_lie
round(p_ab_lie, 4)
## [1] 0.1192
b. What is the probability that an individual is actually a truth-teller given that the polygraph detected him/her as such?
The probability is 0.7784.
# A = An individual is a real truth-teller
# B = The polygraph detects a truth-teller
# P(B): The probability of the polygraph detecting a real truth-teller
p_b_truth <- (ind_lie * p_fail_detect_truth) + (ind_truth * p_detect_truth)
# P(B|A): The probability that given a real truth-teller, the polygraph detects it
p_ba_truth <- ind_truth * p_detect_truth
# P(A|B): The probability that that given the polygraph detecting a truth-teller, the individual is really a truth-teller
p_ab_truth <- (p_ba_truth * ind_truth) / p_b_truth
round(p_ab_truth, 4)
## [1] 0.7784
c. What is the probability that a randomly-selected individual is either a liar or was identified as a liar by the polygraph? Be sure to write the probability statement.
\[ \begin{align} P(\text{real liar} \ \cup \ \text{detected liar} ) \ =& \ P(\text{real liar}) + {P(\text{detected liar})}-P(\text{real liar} \ \cap \ \text{detected liar} ) \end{align} \]
p_liar_or_identified <- ind_lie + p_detect_lie - (ind_lie * p_ba_lie)
p_liar_or_identified
## [1] 0.7664