#total marbles
total_marbles <- 54 + 9 + 75
# Probability it is a red marble
p_of_red <- 54 / total_marbles
# Probability it is a blue marble
p_of_blue <- 75 /total_marbles
# P(red or blue) = P(red) + P(blue)
round(p_of_red + p_of_blue, 4)
## [1] 0.9348
17 yellow golf balls, randomly gives you your ball. What is the probability that you end up with a red golf ball? Express your answer as a simplified fraction or a decimal rounded to four decimal places.
#total balls
total_balls <- 19 + 20 + 24 + 17
# Probability it is a red
p_of_red <- 20 / total_balls
# P(red)
round(p_of_red, 4)
## [1] 0.25
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.
# Total customers(males and females)
t <- 81 + 116 + 215 + 130 + 129 + 228 + 79 + 252 + 97 + 72
# The only combination which does not satisfy either "not male"
# or "not living with parents" are males living with their parents
p_notmale_withparent <- (t - 215)/t
round(p_notmale_withparent, 4)
## [1] 0.8463
Answer: A) Dependent B) Independent
# to choose 3 vegetables from a total of 8 vegetable options
vg <- choose(8, 3)
# to choose 3 condiments from 7 condiment options
ct <- choose(7, 3)
# to choose a tortilla from 3 tortilla options
tl <- choose(3, 1)
# total possible combinations
(t <- vg * ct * tl)
## [1] 5880
Answer: A) Dependent B) Independent
factorial (14) / factorial (14-8)
## [1] 121080960
# to get 3 green out of 9
green <- choose(9, 3)
# Combinations of 1 orange out of 4
orange <- choose(4, 1)
# for 0 red out of 9
red <- choose(9, 0)
# Multiplying all combinations
c <- green * red * orange
#combining all
c_all <- choose((9 + 4 + 9), 4)
# Probability of picking 1 orange and 3 green jellybeans when seleting a total of 4 from 22 jellybeans
round(c/c_all, 4)
## [1] 0.0459
factorial (11) / factorial (7)
## [1] 7920
#total tosses
t <- 2^4
#all possible outcomes
no_head <- choose(4, 0)/t
one_head <- choose(4,1)/t
two_head <- choose(4,2)/t
three_head <- choose(4, 3)/t
four_head <- choose(4, 4)/t
#probability for head
head <- c(no_head, one_head, two_head, three_head, four_head)
head_num <- 0:4
df <- data.frame(head_num, head)
plot(df, main = "probability distribution of four tosses on a histogram", type = "l", col = "green")
values <- c(-30,-30,-30,97, -30)
win <- sum(values * df[,2])
print(paste0("Expected Value of the proposition: $", win))
## [1] "Expected Value of the proposition: $1.75"
exp_win <- 559 * win
print(paste0("I should win: $", exp_win))
## [1] "I should win: $978.25"
Win <- pbinom(4, size=9, prob=1/2)
print(paste0("Probability of 4 tails or less in 9 tosses: ", Win))
## [1] "Probability of 4 tails or less in 9 tosses: 0.5"
exp_wins <- 23*Win + -26*(1 - Win)
print(paste0("The expected value of the proposition: $", round(exp_wins, 2)))
## [1] "The expected value of the proposition: $-1.5"
# If I played this game 994 times
outcome <- 994 * exp_wins
print(paste0("After 994 games, I would you expect to win or lose: $", round(outcome, 2)))
## [1] "After 994 games, I would you expect to win or lose: $-1491"
# Assuming 100, 000 different testers were involved
num_testers <- 100000
# if 20% of the testers are believed to lie, then
lies <- num_testers * 0.20
truth <- num_testers * 0.80
correctlyTested_liars <- 0.59 * lies
(lies_tested_as_truths <- lies - correctlyTested_liars)
## [1] 8200
truths_tested_as_lies <- 0.90 * truth
(correctlyTested_truths <- truth - truths_tested_as_lies)
## [1] 8000
p <- correctlyTested_liars / (correctlyTested_liars + truths_tested_as_lies)
print(paste0("The probability is: ", round(p, 4) * 100, "%"))
## [1] "The probability is: 14.08%"
p2 <- truths_tested_as_lies / (truths_tested_as_lies + lies_tested_as_truths)
print(paste0("The probabi;lity is: ", round(p2, 4) * 100, "%"))
## [1] "The probabi;lity is: 89.78%"
p3 <- lies/num_testers + (correctlyTested_liars + correctlyTested_truths)/num_testers - (correctlyTested_liars) / num_testers
print(paste0("The probability is: ", round(p3, 4) * 100, "%"))
## [1] "The probability is: 28%"