marbles_red <- 54
marbles_white <- 9
marbles_blue <- 75
prob_red_or_blue <- (marbles_red + marbles_blue)/(marbles_red + marbles_blue + marbles_white)
round(prob_red_or_blue,4)
## [1] 0.9348
ball_green <- 19
ball_red <- 20
ball_blue <- 24
ball_yellow <- 17
prob_red <- ball_red/(ball_green + ball_red + ball_blue + ball_yellow)
round(prob_red,4)
## [1] 0.25
3 .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.
males <- 81 + 116 + 215 + 130 + 129
females <- 228 + 79 + 252 + 97 + 72
males_females <- males + females
prob_not_males <- females/males_females
with_parents_females <- 252
prob_not_males_or_not_with_parents <- (females - with_parents_females)/(males_females)
round(prob_not_males_or_not_with_parents,4)
## [1] 0.3402
Answer: A) Dependent B) Independent
Going to gym increases likelihood of loosing weight. The likelihood of loosing some weight increases when a person going to gym. The events are dependant.
choose(8, 3) * choose(7, 3) * choose(3, 1)
## [1] 5880
Two events above don’t affect the probability of each other in general. So, they are independent.
Answer: A) Dependent B) Independent
#it's the case of Permutations without Repetition
#the number of things to choose from
n <- 14
#we choose r of them
r <- 8
factorial(n)/factorial(n-r)
## [1] 121080960
prob <-choose(9, 0) * choose(4, 1) * choose(9, 3)/choose(22, 4)
round(prob,4)
## [1] 0.0459
\[11!/(11-4)!\]
#it's the case of Permutations without Repetition
#the number of things to choose from
n <- 11
#we choose r of them
r <- 4
factorial(n)/factorial(n-r)
## [1] 7920
33% of subscribers to a fitness magazine are the age of 34 and under.
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
#cases with four heads : HHHH, THHH, HTHH, HHTH, HHHT
win_cases <- 5
#all possible cases
#the case of permutations with Repetition
all_cases <- 2^4 #we have 2 possible outcomes(H,T) and we choose 4 of them
all_cases
## [1] 16
prob_win <- win_cases/all_cases
prob_win
## [1] 0.3125
prob_loose <- 1 - prob_win
prob_loose
## [1] 0.6875
#we choose r of them
exp_value <- 97*prob_win - 30*prob_loose
exp_value
## [1] 9.6875
Step 2. If you played this game 559 times how much would you expect to win or lose? (Losses must be entered as negative.)
exp_value *559
## [1] 5415.312
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
#all possible cases
all_cases <- 2^9 #we have 2 possible outcomes(H,T) and we choose 9 of them
#cases with one,two,three and four tails cases
#it's the case of combinations without repetition
cases_one_tail <- factorial(9)/(factorial(1)*(factorial(9-1)))
cases_two_tail <- factorial(9)/(factorial(2)*(factorial(9-2)))
cases_three_tail <- factorial(9)/(factorial(3)*(factorial(9-3)))
cases_four_tail <- factorial(9)/(factorial(4)*(factorial(9-4))) #9 is the number of things to choose from, and we choose 4 of them,no repetition, order doesn't matter.
cases_no_more_four_tails <- cases_one_tail + cases_two_tail + cases_three_tail + cases_four_tail
prob_win <- cases_no_more_four_tails/all_cases
prob_loose <- 1 - prob_win
#we choose r of them
exp_value <- round(23*prob_win - 26*prob_loose,2)
exp_value
## [1] -1.6
Step 2. If you played this game 994 times how much would you expect to win or lose? (Losses must be entered as negative.)
exp_value*994
## [1] -1590.4
prob_liar <- 0.2
sensitivity<- 0.59
specificity <- 0.9
prob_truth_teller <- 1 - prob_liar
false_positve <- 1 - sensitivity
false_negative <- 1 - specificity
prob_liar_detected_liar <- prob_liar * sensitivity
prob_liar_detected_truth_teller <- prob_liar * false_positve
prob_truth_teller_detected_truth_teller <- prob_truth_teller * specificity
prob_truth_teller_detected_liar <- prob_truth_teller * false_negative
prob_detected_liar <- prob_liar_detected_liar + prob_truth_teller_detected_liar
conditional_prob <- prob_liar_detected_liar/prob_detected_liar
round(conditional_prob,4)
## [1] 0.596
prob_detected_truth_teller <- prob_liar_detected_truth_teller + prob_truth_teller_detected_truth_teller
conditional_prob <- prob_truth_teller_detected_truth_teller/prob_detected_truth_teller
round(conditional_prob,4)
## [1] 0.8978
prob_liar + prob_truth_teller_detected_liar
## [1] 0.28