Practice: Computing Probabilities

1) Box with balls

Consider a box containing 10 balls: 4 blue and 6 red, as displayed in the following figure. Assume you pick a 1st ball, then a 2nd ball (no replacement).

Find the probability that:

  1. both balls are blue.

  2. both balls are red.

  3. 1st is blue, 2nd is red.

  4. 1st is red, 2nd is blue.

  5. 2nd is blue, given 1st is red.

  6. 2nd is blue, given 1st is blue.

  7. 1st is blue, given 2nd is red.

  8. at least one of them is blue.

  9. both are of the same color.

  1. (4/10)(3/9) = 12/90
  2. (6/10)(5/9) = 30/90
  3. (4/10)(6/9) = 24/90
  4. (6/10)(4/9) = 24/90
  5. 4/9
  6. 3/9
  7. 4/9
  8. 1 - P(no blues) = 1 - (6/10)(5/9) = 60/90
  9. P(2 blues) + P(2 reds) = (12/90) + (30/90) = 42/90


2) Box with balls and R code

library(tidyverse)

Refer to the box of the preceding problem. The following code allows you to simulate drawing 2 balls from the box 100 times—via replicate(). In order to use tidyverse functions, we need to reshape the simulations output into a data.frame.

set.seed(2024)

box = c(rep("red", 6), rep("blue", 4))

# simulate drawing 2 balls, 100 times
simulations = replicate(
  n = 100,
  expr = sample(box, size = 2))

# table output (as a data frame)
rownames(simulations) = c("first", "second")
balls_df = data.frame(t(simulations))

head(balls_df)
  first second
1   red    red
2   red   blue
3  blue    red
4   red   blue
5  blue    red
6   red    red

Examples

Say we want to approximate probability of getting a first blue ball.

# proportion: 1st ball is blue
balls_df |>
  summarize(prop_1blue = mean(first == "blue"))
  prop_1blue
1       0.44

What if we we want to approximate probability of getting the first ball blue, and the second ball red?

# proportion: 1st is blue, 2nd is red
balls_df |>
  summarize(prop_1blue_2red = mean(first == "blue" & second == "red"))
  prop_1blue_2red
1             0.3

Your Turn

Change the value of set.seed() and increase the number of simulations to 1000. Write R pipelines to approximate the following probabilities. How do these approximations compare to the probabilities you calculated?

  1. Approximate the probability that both balls are blue.
Show answer
balls_df |>
  summarize(mean(first == "blue" & second == "blue"))
  1. Approximate the probability that 1st ball is red, 2nd ball is blue.
Show answer
# b) 1st is red, 2nd is blue
balls_df |>
  summarize(mean(first == "red" & second == "blue"))
  1. Approximate the probability that both balls are red.
Show answer
# c) both are red
balls_df |>
  summarize(mean(first == "red" & second == "red"))
  1. Approximate the probability 1st ball is blue or 2nd ball is blue.
Show answer
# d) 1st is blue OR 2nd is blue
balls_df |>
  summarize(mean(first == "blue" | second == "blue"))
  1. Approximate the probability 2nd ball is blue, given 1st ball is red.
Show answer
# e) 2nd is blue, given that 1st is red
balls_df |>
  filter(first == "red") |>
  summarize(mean(second == "blue"))
  1. Approximate the probability 2nd ball is blue, given 1st ball is blue.
Show answer
# f) 2nd is blue, given that 1st is blue
balls_df |>
  filter(first == "blue") |>
  summarize(mean(second == "blue"))
  1. Approximate the probability 1st ball is blue, given 2nd ball is red.
Show answer
# g) 1st is blue, given that 2nd is red
balls_df |>
  filter(second == "red") |>
  summarize(mean(first == "blue"))


3) Students in STAT 101

Suppose that 35% of students in STAT 101 are from Southern California, 40% are from Northern California, and 25% are from outside California. What is the probability that a student selected at random:

  1. Will be from Southern CA?

  2. Will not be from Northern CA?

  3. Will be from Southern or Northern CA?

  4. Will be from Northern California, given that they are not from Southern CA?

  5. Will be from Northern California, given that they are not from outside CA?

  1. 0.35
  2. 0.35 + 0.25 = 0.6
  3. 0.35 + 0.40 = 0.75
  4. 0.4 / 0.65
  5. 0.4 / 0.75


5) Tickets from a box

Suppose we draw 2 tickets at random without replacement from a box with tickets marked {1, 2, 3, . . . , 9}. Find the probability that:

  1. The first ticket drawn is labeled with an even number.

  2. The second ticket drawn is labeled with an even number.

  3. Both tickets drawn are labeled with an even number.

  4. At least one of the tickets drawn is labeled with an even number.

  5. The first ticket drawn is labeled with a prime number (recall that 1 is not a prime).

  6. The second ticket drawn is labeled with a prime number.

  7. Both tickets drawn are labeled with a prime number.

  8. At least one of the tickets drawn is labeled with a prime number.

  1. (32/72) = 4/9
  2. (32/72) = 4/9
  3. (4/9) (3/8) = 12/72
  4. P(at least one even) = 1 - P(none are even) = 1 - (5/9)(4/8) = 52/72
  5. (32/72) = 4/9
  6. (32/72) = 4/9
  7. (4/9) (3/8) = 12/72
  8. P(at least one prime) = 1 - P(none are prime) = 1 - (5/9)(4/8) = 52/72


6) Matching Probabilities

Match the terms (a-f) with their definitions (i-vi)

Terms

  1. P(A|B) = P(A and B) / P(B)
  2. P(A or B) = P(A) + P(B) - P(A and B)
  3. P(A|B) = P(A)
  4. P(A) = P(B)
  5. P(A and B) = P(B | A) P(A)
  6. P(A and B) = 0

Definitions

  1. equally likely
  2. mutually exclusive
  3. conditional probability
  4. multiplication rule
  5. independence
  6. addition rule
    1. with (d)
    1. with (f)
    1. with (a)
    1. with (e)
    1. with (c)
    1. with (b)


7) Roll a pair of dice

You roll a red die and a blue die, both fair and independent. Find the probability that:

  1. The red die and the blue die both roll 1’s.

  2. The red die and the blue die both roll the same number.

  3. The number on the red die is bigger than the one on the blue die.

  4. The red die rolls a 3.

  5. At least one die rolls a 3.

  6. Exactly one die rolls a 3.

  7. The smallest number on either die is 4.

  8. The largest number on either die is 4.

  9. At least one of the dice rolls a number greater than 4.

  10. Exactly one of the dice rolls a number greater than 4.

  11. The numbers on the dice sum to 7.

  12. The numbers on the dice sum to 4.

  1. 1/36
  2. 1/6
  3. 15/36
  4. 1/6
  5. 11/36
  6. 10/36
  7. 5/36
  8. 7/36
  9. 20/36
  10. 16/36
  11. 6/36
  12. 3/36


8) Students’ Club

A students’ club has 90 members. Fifty are Statistics majors and fifty are Applied Math (A.M.) majors. There are some that are double majoring in Stats and A.M. What is the probability that a member selected at random:

  1. Is a double major?

  2. Is a Stats major but not an A.M. major?

  3. Is an A.M. major but not a Stats major?

  1. 10/90
  2. 40/90
  3. 40/90


9) Finding probabilities

Suppose that A and B are independent events with \(P(A)\) = 0.7, and \(P(B^c)\) = 0.4. Find the following probabilities:

  1. \(P(A^c)\)

  2. \(P(B)\)

  3. \(P(B \text{ and } A)\)

  4. \(P(A \text{ or } B)\)

  5. \(P(A^c \text{ and } B)\)

  6. \(P(B | A)\)

  1. 0.3
  2. 0.6
  3. 0.42
  4. 0.88
  5. 0.18
  6. 0.6