red <- 54
white <- 9
blue <- 75
round((red + blue)/(red + white + blue), 4)
## [1] 0.9348
green <- 19
red <- 20
blue <- 24
yellow <- 17
round((red)/(green + red + blue + yellow), 4)
## [1] 0.25
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
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.
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
Independent - Given Jeff and Liz do not live together/interacted that day
Rank matters, we use permutation here
spots <- 8
candidates <- 14
factorial(candidates)/(factorial(candidates-spots))
## [1] 121080960
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
\[\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
33% of subscribers to a fitness magazine are younger than 34
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"
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"
\[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"
\[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"
\[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