R = 54
W = 9
B = 75
n = R + W + B
#p(R or B) = p(R) + p(B)
p_R_or_B = R/n + B/n
round(p_R_or_B, 4)
## [1] 0.9348
G = 19
R = 20
B = 24
Y = 17
n = G + R + B + Y
p_R = R/n
p_R
## [1] 0.25
library(knitr)
library(kableExtra)
df <- data.frame(Cat = c("Apartment", "Dorm", "With Parent(s)", "Sorority/Fraternity House", "Other", "Total"),
Males = linebreak(c("81", "116", "215", "130", "129", sum(81,116,215,130,129))),
Females = linebreak(c("228", "79", "252", "97", "72", sum(228,79,252,97,72))))
kable(df, col.names = c("", "Males", "Females"), escape = F, caption = "Gender and Residence of Customers") %>%
kable_styling(latex_options = "hold_position")
Males | Females | |
---|---|---|
Apartment | 81 | 228 |
Dorm | 116 | 79 |
With Parent(s) | 215 | 252 |
Sorority/Fraternity House | 130 | 97 |
Other | 129 | 72 |
Total | 671 | 728 |
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.
M_A = 81
M_D = 116
M_Wp = 215
M_SF = 130
M_Ot = 129
M = M_A + M_D + M_Wp + M_SF + M_Ot
F_A = 228
F_D = 79
F_Wp = 252
F_SF = 97
F_Ot = 72
Fe = F_A + F_D + F_Wp + F_SF + F_Ot
Total = M + Fe
Total
## [1] 1399
# p(not M or not Wp) = 1 - p(M_Wp)
p_not_M_or_not_Wp = 1 - M_Wp/Total
p_not_M_or_not_Wp
## [1] 0.8463188
Answer: A) Dependent B) Independent
Solution: A - Dependent
v= choose(8, 3) # 3 vegetables from 8 options
c = choose(7, 3) # 3 Condiments from 7 options
t = choose(3, 1) # 1 tortilla from 3 options
v*c*t # Total possible combinations
## [1] 5880
Answer: A) Dependent B) Independent
Solution: B - Independent
n = 14
r = 8
factorial(n)/ factorial(n-r)
## [1] 121080960
r = 9
o = 4
g = 9
# select 0 red, 1 orange and 3 green
round(choose(9, 0) * choose(4, 1) * choose(9, 3)/choose(22, 4), 4)
## [1] 0.0459
factorial(11)/factorial(7)
## [1] 7920
33% of subscribers to a fitness magazine are below the age of 35. (This includes 34 as part of the complement)
#install.packages("prob")
library(prob)
samp_space = tosscoin(4) == "H"
PA = sum(rowSums(samp_space) == 3)/nrow(samp_space)
PnotA = 1 - PA
EV = PA*97 - PnotA * 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.)
EV * 559
## [1] 978.25
samp_space = tosscoin(9) == "T"
PA = sum(rowSums(samp_space) <= 4)/nrow(samp_space)
PnotA = 1- PA
EV = PA * 23 - PnotA * 26
round(EV, 2)
## [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.)
round(EV * 994, 2)
## [1] -1491
P_liar = 0.2
P_truthteller = 1 - P_liar
sensitivity_rate = 0.59
specificity_rate = 0.9
false_positve_rate = 1 - sensitivity_rate
false_negative_rate = 1 - specificity_rate
P_liar_detectedliar = P_liar * sensitivity_rate
P_liar_detectedtruthteller = P_liar * false_positve_rate
P_truthteller_detectedtruthteller = P_truthteller * specificity_rate
P_truthteller_detectedliar = P_truthteller * false_negative_rate
\[conditionalProb = \frac{P(liar | detectedliar)}{P(detected| liar)}\]
conditional_prob = P_liar_detectedliar/P_liar
conditional_prob
## [1] 0.59
\[P(Truthteller∣DetectedTruthteller)=\frac{P(DetectedTruthteller∣Truthteller)∗P(Truthteller)}{P(DetectedTruthteller)}\]
P_detectedtruthteller_given_truthteller = (P_truthteller_detectedtruthteller/P_truthteller)
round(P_detectedtruthteller_given_truthteller, 4)
## [1] 0.9
\[P(Liar∪DetectedLiar) = P(Liar)+P(DetectedLiar)−P(Liar∩DetectedLiar)\]
P_liar + P_truthteller_detectedliar
## [1] 0.28