1. 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 it is red or blue? Express your answer as a fraction or a decimal number rounded to four decimal places.

#total marbles
total_marbles <- 54 + 9 + 75

# Probability it is a red marble
p_of_red <- 54 / total_marbles

# Probability it is a blue marble
p_of_blue <- 75 /total_marbles

# P(red or blue) = P(red) + P(blue)
round(p_of_red + p_of_blue, 4)
## [1] 0.9348

2. 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.

#total balls
total_balls <- 19 + 20 + 24 + 17

# Probability it is a red
p_of_red <- 20 / total_balls

# P(red)
round(p_of_red, 4)
## [1] 0.25

3. 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.

# Total customers(males and females)
t <- 81 + 116 + 215 + 130 + 129 + 228 + 79 + 252 + 97 + 72

# The only combination which does not satisfy either "not male"
# or "not living with parents" are males living with their parents

p_notmale_withparent <- (t - 215)/t
round(p_notmale_withparent, 4)
## [1] 0.8463

4. Determine if the following events are independent. Going to the gym. Losing weight.

Answer: A) Dependent B) Independent

I will say the events are dependent because going to the gym has a high probability to make you loose weight

5. 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?

# to choose 3 vegetables from a total of 8 vegetable options
vg <- choose(8, 3)

# to choose 3 condiments from 7 condiment options
ct <- choose(7, 3)

# to choose a tortilla from 3 tortilla options
tl <- choose(3, 1)

# total possible combinations
(t <- vg * ct * tl)
## [1] 5880

6. Determine if the following events are independent. Jeff runs out of gas on the way to work. Liz watches the evening news.

Answer: A) Dependent B) Independent

These are seemingly independent events as Liz watching the news is very unlikely to influence Jeff’s gas tank on his way to work.

7. 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

8. 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.

# to get 3 green out of 9
green <- choose(9, 3)

# Combinations of 1 orange out of 4
orange <- choose(4, 1)

# for 0 red out of 9
red <- choose(9, 0)

# Multiplying all combinations
c <- green * red * orange

#combining all
c_all <- choose((9 + 4 + 9), 4)

# Probability of picking 1 orange and 3 green jellybeans when seleting a total of 4 from 22 jellybeans
round(c/c_all, 4)
## [1] 0.0459

9. Evaluate the following expression. 11!/7!

factorial (11) / factorial (7)
## [1] 7920

10. Describe the complement of the given event. 67% of subscribers to a fitness magazine are over the age of 34.

Answer: The Compliment is that 33% of subscribers to a fitness magazine are 34 years old or younger.

11. 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.

probability distribution with four tosses:

#total tosses
t <- 2^4

#all possible outcomes
no_head <- choose(4, 0)/t
one_head <- choose(4,1)/t
two_head <- choose(4,2)/t
three_head <- choose(4, 3)/t
four_head <- choose(4, 4)/t

#probability for head
head <- c(no_head, one_head, two_head, three_head, four_head)
head_num <- 0:4

df <- data.frame(head_num, head)

plot(df, main = "probability distribution of four tosses on a histogram", type = "l", col = "green")

How much I am going to win if I get the right tosses

values <- c(-30,-30,-30,97, -30)

win <- sum(values * df[,2])
print(paste0("Expected Value of the proposition: $", win))
## [1] "Expected Value of the proposition: $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.)

exp_win <- 559 * win
print(paste0("I should win: $", exp_win))
## [1] "I should win: $978.25"

12. Flip a coin 9 times. If you get 4 tails or less, I will pay you $23. Otherwise you pay me $26.

Step 1. Find the expected value of the proposition. Round your answer to two decimal places.

Win <- pbinom(4, size=9, prob=1/2)
print(paste0("Probability of 4 tails or less in 9 tosses: ", Win))
## [1] "Probability of 4 tails or less in 9 tosses: 0.5"
exp_wins <- 23*Win + -26*(1 - Win)
print(paste0("The expected value of the proposition: $", round(exp_wins, 2)))
## [1] "The expected value of the proposition: $-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.)

# If I played this game 994 times
outcome <- 994 * exp_wins
print(paste0("After 994 games, I would you expect to win or lose: $", round(outcome, 2)))
## [1] "After 994 games, I would you expect to win or lose: $-1491"

13. 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 that the probability of detecting a “truth teller” was .90 (specificity). We estimate that about 20% of individuals selected for the screening polygraph will lie.

# Assuming 100, 000 different testers were involved
num_testers <- 100000

# if 20% of the testers are believed to lie, then
lies <- num_testers * 0.20
truth <- num_testers * 0.80
How many liars will/not be picked up by the test knowing that sensitivity detects the probability of a tester being a liar
correctlyTested_liars <- 0.59 * lies
(lies_tested_as_truths <- lies - correctlyTested_liars)
## [1] 8200

The probability of detecting a “truth teller” was .90 (specificity) assuming they are actually telling the truth

truths_tested_as_lies <- 0.90 * truth
(correctlyTested_truths <- truth - truths_tested_as_lies)
## [1] 8000

a. What is the probability that an individual is actually a liar given that the polygraph detected him/her as such? (Show me the table or the formulaic solution or both.)

p <- correctlyTested_liars / (correctlyTested_liars + truths_tested_as_lies)
print(paste0("The probability is: ", round(p, 4) * 100, "%"))
## [1] "The probability is: 14.08%"

b. What is the probability that an individual is actually a truth-teller given that the polygraph detected him/her as such? (Show me the table or the formulaic solution or both.)

p2 <- truths_tested_as_lies / (truths_tested_as_lies + lies_tested_as_truths)
print(paste0("The probabi;lity is: ", round(p2, 4) * 100, "%"))
## [1] "The probabi;lity is: 89.78%"

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.

p3 <- lies/num_testers + (correctlyTested_liars + correctlyTested_truths)/num_testers - (correctlyTested_liars) / num_testers
print(paste0("The probability is: ", round(p3, 4) * 100, "%"))
## [1] "The probability is: 28%"