red <- 54
white <- 9
blue <- 75
total <- red + white + blue
p.red <- red / total
p.white <- white / total
p.blue <- blue / total
p.red.or.blue <- p.red + p.blue
p.red.or.blue
## [1] 0.9347826
p.red <- 20 / (19+20+24+17)
p.red
## [1] 0.25
print("Gender and Residence of Customer")
## [1] "Gender and Residence of Customer"
output
## Males Females
## Apartment 81 228
## Dorm 116 79
## with Parents 215 252
## Sorority/Fraternity House 130 97
## Other 129 72
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 <- 81+228+116+79+215+252+130+97+129+72
# The only combination that does not satisfy "Not Male" or "Not living with parents"
# are male living with their parents, thus
(total - 215) / total
## [1] 0.8463188
Going to the gym. Losing weight.
Answer: A) Dependent
Unless you go to the gym and don’t exercise.
# Number of options you can choose 3 veggies from 9 veggies options
v <- choose(8, 3)
# Number of options you can choose 3 condiments from 7 condiments options
c <- choose(7, 3)
# Number of options you can choose tortilla from 3 tortilla optoons
t <- 3
v*c*t
## [1] 5880
Jeff runs out of gas on the way to work. Liz watches the evening news.
Answer: B) Independent
factorial(14)/factorial(14-8)
## [1] 121080960
# 1 orange out of 4, 3 green out of 9, divided by all possible combs
choose(4, 1) * choose(9, 3) / choose((9+4+9), 4)
## [1] 0.04593301
\(\frac{11!}{7!}\)
factorial(11) / factorial(7)
## [1] 7920
67% of subscribers to a fitness magazine are over the age of 34.
Compliment: 33% of subscribers to a fitness magazine are 34 years old or younger.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
v <- choose(4, 3) * (1/2)^4
Step 2. If you played this game 559 times how much would you expect to win or lose? (Losses must be entered as negative.)
# probability of not exactly three heads
n <- 1 - v
# winning for 559 plays
559 * (( v * 97) - (n * 30))
## [1] 978.25
After 559 times, I would expect to win 978.25 USD.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
v <- pbinom(4, size=9, prob=0.5)
v
## [1] 0.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.)
# probability of not tossing 4 tails or less
n <- 1-v
# winning for 994 plays
994 * ( (v*23) - (n*26) )
## [1] -1491
After 994 times, I would expect to lose 1,491 USD.
\[ \begin{split} P(Liar|Detect^-) &= \frac{P(Detect^-|Liar)\times P(Liar)}{P(Detect^-)} \\ &= \frac{P(Detect^-|Liar)\times P(Liar)}{P(Liar)\times P(Detect^-|Liar)+P(Truth\ Teller)\times P(Detect^-|Truth\ Teller)} \\ &= \frac{0.59\times0.2}{0.2\times0.59+0.8\times0.1}\\ &=\frac{0.118}{0.198}\approx 0.596 \end{split} \]
# p(actual liar | polygraph detected as a liar)
# P(A|B) = P(B|A)P(A) / P(B)
# P(actual liar) = P(A) = 0.2
# P(B) = P(A) * P(B|A) + P(Truth Teller) * P(B|Truth Teller)
# P(detected as liar) = P(B) = (0.8 * 0.1) + (0.2*0.59)
(0.2 * 0.59) / ( (0.2 * 0.59) + (0.8 * 0.1) )
## [1] 0.5959596
\[ \begin{split} P(Truth\ Teller|Detect^+) &= \frac{P(Detect^+|Truth\ Teller)\times P(Truth\ Teller)}{P(Detect^+)} \\ &= \frac{P(Detect^+|Truth\ Teller)\times P(Truth\ Teller)}{P(Liar)\times P(Detect^+|Liar)+P(Truth\ Teller)\times P(Detect^+|Truth\ Teller)} \\ &= \frac{0.9\times0.8}{0.2\times0.41+0.8\times0.9} \\ &=\frac{0.72}{0.802} \approx 0.8978 \end{split} \]
# p(actual truth teller | detected truth teller)
# P(A|B) = P(B|A)P(A) / P(B)
# P(detected truth teller) = P(B) = P(Liar) * P(detected truth teller|liar) + P(Truth teller) * P(detected truth teller|truth teller) = 0.2 * 0.41 + 0.9 * 0.9
(0.8 * 0.9) / ( (0.8 * 0.9) + (0.2 * 0.41) )
## [1] 0.8977556
0.2 + 0.198 - 0.2 * 0.59
## [1] 0.28