Discussion 5: Probability and Simulation

← return to practice.dsc10.com


The problems in this worksheet are taken from past exams. Work on them on paper, since the exams you take in this course will also be on paper.

We encourage you to complete this worksheet in a live discussion section. Solutions will be made available after all discussion sections have concluded. You don’t need to submit your answers anywhere.

Note: We do not plan to cover all problems here in the live discussion section; the problems we don’t cover can be used for extra practice.


Problem 1

You generate a three-digit number by randomly choosing each digit to be a number 0 through 9, inclusive. Each digit is equally likely to be chosen.


Problem 1.1

What is the probability you produce the number 027? Give your answer as a decimal number between 0 and 1 with no rounding.


Problem 1.2

What is the probability you produce a number with an odd digit in the middle position? For example, 250. Give your answer as a decimal number between 0 and 1 with no rounding.


Problem 1.3

What is the probability you produce a number with a 7 in it somewhere? Give your answer as a decimal number between 0 and 1 with no rounding.



Problem 2

Suppose you are booking a flight and you have no control over which airline you fly on. Below is a table with multiple airlines and the probability of a flight being on a specific airline.

Airline Chance
Delta 0.4
United 0.3
American 0.2
All other airlines 0.1

The airline for one flight has no impact on the airline for another flight.

For this question, suppose that you schedule 3 flights for January 2022.


Problem 2.1

What is the probability that all 3 flights are on United? Give your answer as an exact decimal between 0 and 1 (not a Python expression).


Problem 2.2

What is the probability that all 3 flights are on Delta, or all on United, or all on American? Give your answer as an exact decimal between 0 and 1 (not a Python expression).


Problem 2.3

True or False: The probability that all 3 flights are on the same airline is equal to the probability you computed in the previous subpart.



Problem 3

King Triton has boarded a Southwest flight. For in-flight refreshments, Southwest serves four types of cookies – chocolate chip, gingerbread, oatmeal, and peanut butter.

The flight attendant comes to King Triton with a box containing 10 cookies:

The flight attendant tells King Triton to grab 2 cookies out of the box without looking.

Fill in the blanks below to implement a simulation that estimates the probability that both of King Triton’s selected cookies are the same.

# 'cho' stands for chocolate chip, 'gin' stands for gingerbread,
# 'oat' stands for oatmeal, and 'pea' stands for peanut butter.

cookie_box = np.array(['cho', 'cho', 'cho', 'cho', 'gin', 
                       'gin', 'gin', 'oat', 'oat', 'pea'])

repetitions = 10000
prob_both_same = 0
for i in np.arange(repetitions):
    grab = np.random.choice(__(a)__)
    if __(b)__:
        prob_both_same = prob_both_same + 1
prob_both_same = __(c)__


Problem 3.1

What goes in blank (a)?


Problem 3.2

What goes in blank (b)?


Problem 3.3

What goes in blank (c)?



Problem 4

Each individual penguin in our dataset is of a certain species (Adelie, Chinstrap, or Gentoo) and comes from a particular island in Antarctica (Biscoe, Dream, or Torgerson). There are 330 penguins in our dataset, grouped by species and island as shown below.


Suppose we pick one of these 330 penguins, uniformly at random, and name it Chester.


Problem 4.1

What is the probability that Chester comes from Dream island? Give your answer as a number between 0 and 1, rounded to three decimal places.


Problem 4.2

If we know that Chester comes from Dream island, what is the probability that Chester is an Adelie penguin? Give your answer as a number between 0 and 1, rounded to three decimal places.


Problem 4.3

If we know that Chester is not from Dream island, what is the probability that Chester is not an Adelie penguin? Give your answer as a number between 0 and 1, rounded to three decimal places.



Problem 5

The fine print of the Sun God festival website says “Ticket does not guarantee entry. Venue subject to capacity restrictions.” RIMAC field, where the 2022 festival will be held, has a capacity of 20,000 people. Let’s say that UCSD distributes 21,000 tickets to Sun God 2022 because prior data shows that 5% of tickets distributed are never actually redeemed. Let’s suppose that each person with a ticket this year has a 5% chance of not attending (independently of all others). What is the probability that at least one student who has a ticket cannot get in due to the capacity restriction? Fill in the blanks in the code below so that prob_angry_student evaluates to an approximation of this probability.

num_angry = 0

for rep in np.arange(10000):
    # randomly choose 21000 elements from [True, False] such that 
    # True has probability 0.95, False has probability 0.05
    attending = np.random.choice([True, False], 21000, p=[0.95, 0.05])
    if __(a)__:
        __(b)__

prob_angry_student = __(c)__


Problem 5.1

What goes in the first blank?


Problem 5.2

What goes in the second blank?


Problem 5.3

What goes in the third blank?



Problem 6


Problem 6.1

You’re definitely going to Sun God 2022, but you don’t want to go alone! Fortunately, you have n friends who promise to go with you. Unfortunately, your friends are somewhat flaky, and each has a probability p of actually going (independent of all others). What is the probability that you wind up going alone? Give your answer in terms of p and n.


Problem 6.2

In past Sun God festivals, sometimes artists that were part of the lineup have failed to show up! Let’s say there are n artists scheduled for Sun God 2022, and each artist has a probability p of showing up (independent of all others). What is the probability that the number of artists that show up is less than n, meaning somebody no-shows? Give your answer in terms of p and n.



Problem 7

True or False: If you roll two dice, the probability of rolling two fives is the same as the probability of rolling a six and a three.


Problem 8

The HAUGA bedroom furniture set includes two items, a bed frame and a bedside table. Suppose the amount of time it takes someone to assemble the bed frame is a random quantity drawn from the probability distribution below.

Time to assemble bed frame Probability
10 minutes 0.1
20 minutes 0.4
30 minutes 0.5

Similarly, the time it takes someone to assemble the bedside table is a random quantity, independent of the time it takes them to assemble the bed frame, drawn from the probability distribution below.

Time to assemble bedside table Probability
30 minutes 0.3
40 minutes 0.4
50 minutes 0.3


Problem 8.1

What is the probability that Stella assembles the bed frame in 10 minutes if we know it took her less than 30 minutes to assemble? Give your answer as a decimal between 0 and 1.


Problem 8.2

What is the probability that Ryland assembles the bedside table in 40 minutes if we know that it took him 30 minutes to assemble the bed frame? Give your answer as a decimal between 0 and 1


Problem 8.3

What is the probability that Jin assembles the complete HAUGA set in at most 60 minutes? Give your answer as a decimal between 0 and 1.



Problem 9

King Triton had four children, and each of his four children started their own families. These four families organize a Triton family reunion each year. The compositions of the four families are as follows:

Suppose we choose one of the fifteen people at the Triton family reunion at random.


Problem 9.1

Given that the chosen individual is from a family with one child, what is the probability that they are from Family X? Give your answer as a simplified fraction.


Problem 9.2

Consider the events A and B, defined below.

True or False: Events A and B are independent.


Problem 9.3

Consider the events C and D, defined below.

True or False: Events C and D are independent.


Problem 9.4

At the reunion, the Tritons play a game that involves placing the four letters into a hat (W, X, Y, and Z, corresponding to the four families). Then, five times, they draw a letter from the hat, write it down on a piece of paper, and place it back into the hat.

Let p = \frac{1}{4} in the questions that follow.

What is the probability that Family W is selected all 5 times?



Problem 9.5

What is the probability that Family W is selected at least once?


Problem 9.6

What is the probability that Family W is selected exactly once, as the last family that is selected?



👋 Feedback: Find an error? Still confused? Have a suggestion? Let us know here.