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.
red <- 54
white <- 9
blue <- 75

round((red + blue)/(red + white + blue), 4)
## [1] 0.9348
  1. 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.
green <- 19
red <- 20
blue <- 24
yellow <- 17

round((red)/(green + red + blue + yellow), 4)
## [1] 0.25
  1. 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.

not_male <- 228 + 79 + 252 + 97 + 72
not_live_parents <- 81 + 228 + 116 + 79 + 130 + 97 + 129 + 72

not_male_percent <- not_male/1399
not_live_parents_percent <- not_live_parents/1399
interaction_percent <- (228 + 79 + 97 + 72)/1399

round(not_male_percent+not_live_parents_percent-interaction_percent, 4)
## [1] 0.8463
  1. Determine if the following events are independent. Going to the gym. Losing weight.

Dependent - One action has affected the outcome of another. One would have to exert effort getting to/at the gym for this to be the dependent variables.

  1. 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?
veggies <- 8
condiments <- 7
tortillas <- 3

veggie_combos <- factorial(veggies)/(factorial(veggies-3)*factorial(3))
condiment_combos <- factorial(condiments)/(factorial(condiments-3)*factorial(3)) 
tortillas_combos <- factorial(tortillas)/(factorial(tortillas-1)*factorial(1))

veggie_combos * condiment_combos * tortillas_combos
## [1] 5880
  1. Determine if the following events are independent. Jeff runs out of gas on the way to work. Liz watches the evening news.

Independent - Given Jeff and Liz do not live together/interacted that day

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

Rank matters, we use permutation here

spots <- 8
candidates <- 14

factorial(candidates)/(factorial(candidates-spots))
## [1] 121080960
  1. 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.
red <- 9
orange <- 4
green <- 9

red <- factorial(red)/(factorial(red-0)*factorial(0))
orange <- factorial(orange)/(factorial(orange-1)*factorial(1))
green <- factorial(green)/(factorial(green-3)*factorial(3))
total <- factorial(22)/(factorial(22 - 4)*factorial(4))

round((red*orange*green)/total, 4)
## [1] 0.0459
  1. Evaluate the following expression.

\[\dfrac{11!}{7!}\]

\[=\dfrac{11 * 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1}{7*6*5*4*3*2*1} \] \[=11 * 10 * 9 * 8 \]

factorial(11)/factorial(7)
## [1] 7920
11*10*9*8
## [1] 7920
  1. Describe the complement of the given event. 67% of subscribers to a fitness magazine are over the age of 34.

33% of subscribers to a fitness magazine are younger than 34

  1. If you throw exactly three heads in four tosses of a coin you win 97 dollars. If not, you pay me 30 dollars.

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

total <- 2^4
zero_heads <- factorial(4)/(factorial(4-0)*factorial(0))/total
one_heads <- factorial(4)/(factorial(4-1)*factorial(1))/total
two_heads <- factorial(4)/(factorial(4-2)*factorial(2))/total
three_heads <- factorial(4)/(factorial(4-3)*factorial(3))/total
four_heads <- factorial(4)/(factorial(4-4)*factorial(4))/total

heads_prob <- data.frame(c(zero_heads, one_heads, two_heads, three_heads, four_heads))
gamble <- c(-30,-30,-30,97,-30)
(exp_value <- sum(gamble * heads_prob[,1]))
## [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.)

paste("You would expect to win $",559*exp_value)
## [1] "You would expect to win $ 978.25"
  1. Flip a coin 9 times. If you get 4 tails or less, I will pay you 23 dollars. Otherwise you pay me 26 dollars.

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

for (i in 0:4){
  value <- choose(9, i)
  value <- value + value
}

four_or_less <- round(value/(2^9), 2)
five_or_more <- 1-four_or_less

(exp_value <- sum(four_or_less * 23, five_or_more * -26))
## [1] -1.99

Step 2. If you played this game 994 times how much would you expect to win or lose? (Losses must be entered as negative.)

paste("You would expect to win $", exp_value*994)
## [1] "You would expect to win $ -1978.06"
  1. 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.
  1. 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(liar\quad | \quad detected \quad liar) = \dfrac{P(detected\quad liar \quad |\quad liar)}{P(detected \quad liar)}\]

\[P(liar\quad | \quad detected \quad liar) = \dfrac{P(detected\quad liar \quad |\quad liar)}{P((1 - percent \quad liar) + (1 - percent \quad truth))+P((percent \quad lie)+(liar)))}\]

\[P(liar\quad | \quad detected \quad liar) = \dfrac{(.59 \quad*\quad .2)}{((.8 \quad* \quad.1) \quad+ \quad(.2\quad *\quad .59))}\]

liar <- .59
truth_teller <- .9
percent_will_lie <- .2

probliargivenlie <- ((liar * percent_will_lie))/(((1-percent_will_lie) * (1-truth_teller)) + (percent_will_lie * liar))

paste("P(liar | detected lie) =", round(probliargivenlie, 4))
## [1] "P(liar | detected lie) = 0.596"
  1. 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.)

\[P(truth\quad | \quad detected \quad truth) = \dfrac{P(detected\quad truth \quad |\quad truth)}{P(detected \quad truth)}\]

\[P(truth\quad | \quad detected \quad truth) = \dfrac{P(detected\quad truth \quad |\quad truth)}{P((1 - liar) + (percent \quad lie))+P((truth)+(1-(percent\quad lie)))}\]

\[P(truth\quad | \quad detected \quad truth) = \dfrac{(.9 \quad*\quad .8)}{((.41 \quad* \quad.2) \quad+ \quad(.9\quad *\quad .8))}\]

liar <- .59
truth_teller <- .9
percent_will_lie <- .2

probtruthgiventruth <- (((truth_teller) * (1-percent_will_lie)))/(((1-liar) * (percent_will_lie)) + (truth_teller * (1-percent_will_lie)))

paste("P(truth | detected truth) =", round(probtruthgiventruth, 4))
## [1] "P(truth | detected truth) = 0.8978"
  1. 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.

\[P(liar\quad ∪ \quad identified \quad liar) = P(liar) + P(identified \quad liar) - P(liar \quad ∩ \quad identified \quad liar)\]

\[P(liar\quad ∪ \quad identified \quad liar) = P(liar) + P(identified \quad liar) - P(liar \quad | \quad identified \quad liar)\]

percent_will_lie <- .2
liar <- .59
problem_a <- 0.596

(liar + percent_will_lie) - problem_a
## [1] 0.194