red <- 54
white <- 9
blue <- 75
total <- red+white+blue
red/total+blue/total## [1] 0.9347826
green <- 19
red <- 20
blue <- 24
yellow <- 17
red/(green+red+blue+yellow)## [1] 0.25
# probability is male and lives with parents is the category male lives with parents= 215
male_w_parents <- 215
total <- 1399
1-(male_w_parents/total)## [1] 0.8463188
\[{{8}\choose{3}}\cdot{{7}\choose{3}}*{{3}\choose{1}} \]
choose(8,3)*choose(7,3)*choose(3,1)## [1] 5880
perm <- function(n,k){choose(n,k) * factorial(k)}
perm(14,8)## [1] 121080960
\[ P_{(red)}+P_{(orange)}+P_{(green)} \]
\[ ({{9}\choose{0}}*{{4}\choose{1}}*{{9}\choose{3}})/{{22}\choose{4}}\]
(choose(9,0)*choose(4,1)*choose(9,3))/choose(22,4)## [1] 0.04593301
factorial(11)/factorial(7)## [1] 7920
choose(4,3)*.5**3*.5**1## [1] 0.25
prob <- .25
prob_comp <- .75
wage_won <- 97
wage_lost <- 30
total_earned <- prob*wage_won -(prob_comp*wage_lost)
total_earned## [1] 1.75
559*total_earned## [1] 978.25
probablity_count <- c()
n=9
j=0
while (j<5){
new_count <- choose(n,j)*.5**(j)*.5**(n-j)
probablity_count <- append(probablity_count,new_count)
j=j+1
}
print(sum(probablity_count))## [1] 0.5
prob_win <- sum(probablity_count)my_ev <- prob_win*23-((1-prob_win)*26)
print(my_ev)## [1] -1.5
my_ev*994## [1] -1491
PPV
liars <- .2
truth <- .8
sensitivity <- .59
# therefore FP
FP<- .41
specificity <- .9
FN <- .1
falsey_identified_liar <- truth*F
P_Liar_given_positive_test <- (liars * sensitivity) / ( liars * sensitivity+ (1 -liars)*(1-specificity))
P_Liar_given_positive_test## [1] 0.5959596
B. Find NPV
NPV
NPV <- specificity*(.8) / (specificity*(.8)+ (FP*liars))liars+ (liars * sensitivity+ (1 -liars)*(1-specificity))-(liars * sensitivity)## [1] 0.28