red = 54
white = 9
blue = 75
total = red + white + blue
prob_red_or_blue <- (red + blue)/total
round(prob_red_or_blue, 4)
## [1] 0.9348
g_golf_balls = 19
r_golf_balls = 20
b_golf_balls = 24
y_golf_balls = 17
total <- g_golf_balls + r_golf_balls + b_golf_balls + y_golf_balls
red_ball_prob <- r_golf_balls/total
round(red_ball_prob, 4)
## [1] 0.25
pizza_frame <- data.frame(c(81,116, 215, 130, 129), c(228,79,252,97,72), c(309,195,467,227,201))
names(pizza_frame) <- c("Males", "Females", "Total")
row.names(pizza_frame) <- c("Apartment", "Dorm", "With Parents(s)", "Sorority/Fraterniy House", "Other")
pizza_frame
## Males Females Total
## Apartment 81 228 309
## Dorm 116 79 195
## With Parents(s) 215 252 467
## Sorority/Fraterniy House 130 97 227
## Other 129 72 201
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
P_female = sum(pizza_frame$Females)/sum(pizza_frame$Total)
P_Not_Parents = 1 - (467/sum(pizza_frame$Total))
P_Female_Not_Parents = (sum(pizza_frame$Females) - 252)/sum(pizza_frame$Total)
Answer <- (P_female + P_Not_Parents) - P_Female_Not_Parents
round(Answer, 4)
## [1] 0.8463
Answer: Dependent. Going to the gym and presumably exercising is going to affect whether you lose weight.
veggie_ans <- choose(8,3) * choose(7,3) * choose(3,1)
veggie_ans
## [1] 5880
Jeff runs out of gas on the way to work. Liz watches the evening news.
Answer: Independent.
factorial(14)/factorial(14-8)
## [1] 121080960
bag_prob <- choose(9,0) * choose(4,1) * choose(9,3)
answer_jelly <- bag_prob/choose(22, 4)
round(answer_jelly, 4)
## [1] 0.0459
factorial(11)/factorial(7)
## [1] 7920
10.Describe the complement of the given event.
67% of subscribers to a fitness magazine are over the age of 34.
Complement = 1-0.67
Complement
## [1] 0.33
print("33% of the other subscribers are under or at 34 years of age.")
## [1] "33% of the other subscribers are under or at 34 years of age."
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
proposition_win <- dbinom(3, 4, 0.5, log = FALSE)
prop_loss <- 1 - proposition_win
expected_value <- (97*proposition_win)-(30 * prop_loss)
round(expected_value, 2)
## [1] 1.75
Step 2. Step 2. If you played this game 559 times how much would you expect to win or lose? (Losses must be entered as negative.)
step2_answer <- expected_value * 559
step2_answer
## [1] 978.25
12.Flip a coin 9 times. If you get 4 tails or less, I will pay you $23. Otherwise you pay me $26
Step 1. Find the expected value of the proposition. Round your answer to two decimal places.
series <- seq(1, 4, by = 1)
prob <- dbinom(series, 9, 0.5, log = FALSE)
tot_val_prob <- round(sum(prob), 2)
losing_prob <- 1 - tot_val_prob
answer_12<- (23 * tot_val_prob) - (26 * losing_prob)
answer_12
## [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.)
expect_win_loss <- answer_12 * 994
expect_win_loss
## [1] -1491
Assumption: 1,000 individuals are used
prob_liar <- .2
polygraph_liar <- .59
polygraph_truth <- .9
total_liars <- 1000 * prob_liar
total_truth_sayers <- 1000 - total_liars
polygraph_correct_liar <- total_liars * polygraph_liar
polygraph_correct_truth <- total_truth_sayers * polygraph_truth
polygraph_inc_liar <- total_liars - polygraph_correct_liar
polygraph_inc_truth <- total_truth_sayers - polygraph_correct_truth
t1 <- 118 + 720
t2 <- 82 + 80
t3 <- 200 + 800
df <- data.frame(c(polygraph_correct_liar,polygraph_inc_liar,total_liars), c(polygraph_correct_truth, polygraph_inc_truth, total_truth_sayers), c(t1, t2, t3))
names(df) <- c("Liars", "Truth", "Total")
row.names(df) <- c("Polygraph Correct", "Polygraph Incorrect", "Total")
df
## Liars Truth Total
## Polygraph Correct 118 720 838
## Polygraph Incorrect 82 80 162
## Total 200 800 1000
actual_liar_prob <- df[1,1]/(df[2,2] + df[1,1])
actual_liar_prob
## [1] 0.5959596
actual_truth_prob <- df[1,2]/(df[1,2] + df[2,1])
actual_truth_prob
## [1] 0.8977556
c.What is the probability that a randomly selected individual is either a liar or was identified as a liar by the polygraph?
Answer: 0.28
#Add up the real liars (detected or not) and the amount of people incorrectly identified as a liar
(polygraph_correct_liar + polygraph_inc_truth + polygraph_inc_liar)/1000
## [1] 0.28