Topic 5: Discrete Probability Distributions
This activity provides an introduction to discrete probability, including basic probability through counting outcomes, and calculating probabilities associated with outcomes of binomial experiments using the binomial distribution.
Discrete Probability Distributions
Throughout this activity you’ll be introduced to the notion of probability and will explore applications of probability and discrete random variables. After developing some intuition using foundational probability ideas, we’ll focus on binomial experiments and using the binomial distribution to find probabilities of prescribed outcomes.
There are entire courses devoted to probability – we will only cover probability to the extent that it is necessary for use in this course. If you are interested in a more detailed treatment of probability, seek out one of the many great courses available.
Objectives
Activity Objectives: After completing this workbook you should be able to:
- Define, discuss, and interpret the probability of an event as its likelihood.
- Apply fundamental counting principles and the notion of independence to compute the probability associated with the occurrence of a sequence of events.
- Use the definition of binomial experiments to identify scenarios to which the binomial distribution can be applied.
- Apply the binomial distribution in appropriate scenarios to find probabilities associated with specified outcomes.
- Given a binomial experiment, compute the expected number of successful outcomes as well as the standard deviation for number of successes.
Basic Probability
Definition of Probability (frequentist): For a given random process, the probability of an event \(A\) is the proportion of time we would observe an outcome satisfying \(A\) if the random process were repeated an infinite number of times.
Example: Given a fair coin, the probability of a flip turning up heads is \(0.5\) (or 50%). Similarly, given a fair six-sided die, the probability of a roll resulting in a number greater than four is \(1/3\) (or about 33.3%) because there are two outcomes satisfying the criteria (rolling a 5 or rolling a 6) out of the six total possible outcomes.
Try It! Now it is your turn. Try the next few problems. Be sure to note any questions you have as you work through them.
Given one fair, six-sided die, what is the probability of rolling a three?
Given one fair, six-sided die, what is the probability of rolling a two, four, or six?
Given two fair, six-sided dice, which is larger?
Good work on that last set of questions. In those problems you could find the probability by counting the number of ways the desired outcome could occur and then dividing that number by the total number of outcomes possible. In the last question, there were simply more ways to roll a five (four ways to do it) than to roll a two (just one way).
What if we try doing something a bit more complicated? Say we wanted to know the probability of rolling at least a two on a single roll of a die and then flipping a “tails” on a single flip of a coin?
If \(A\) and \(B\) are independent events (that is, the probability that \(B\) occurs does not depend on whether or not \(A\) occurred, and vice-versa), then the probability of \(A\) and \(B\) occurring is the product of the probability of \(A\) occurring and the probability of \(B\) occurring. Mathematically, we write: \(\mathbb{P}\left[A~\text{and}~B\right] = \mathbb{P}\left[A\right]\cdot\mathbb{P}\left[B\right]\).
Given a single roll of a fair, six-sided die, what is the probability of rolling at least a two?
Given a single flip of a fair coin, what is the probability of the coin landing with tails facing upwards?
Use the code block below to compute the probability that in a single roll of a fair die and a flip of a coin we observe a roll of at least two and a flip of tails.
Use the probabilities you identified above.
The flip of a coin and roll of a die are independent events.
Since the events are independent, multiply the probabilities of the individual outcomes together.
(___) * (___)Since the events are independent, multiply the probabilities of the individual outcomes together.
(5/6) * (1/2)
(5/6)*(1/2)
(5/6)*(1/2)Good work so far. Let’s say you forgot to study for your chemistry quiz today. It is a four question multiple choice quiz with answer options \(a)\) - \(e)\) on each question. You decide that your best option is to guess randomly on each of the questions. Answer the following, using the empty code block below to carry out any necessary computations.
There are five answer options possible and only one of them is correct.
There are five answer options possible and only one of them is correct. You’re guessing randomly, so no one choice is more likely than any of the others.
There are five answer options possible and only one of them is correct. You’re guessing randomly, so no one choice is more likely than any of the others. By choosing randomly, you have a one out of five (20% or 0.20) probability of selecting the correct answer on any one question.
The questions are independent events here.
The questions are independent events here. Multiply the probability associated with the outcome on each individual question together.
(___)*(___)*(___)*(___)The questions are independent events here. Multiply the probability associated with the outcome on each individual question together. The probability of getting any individual question correct is 0.20.
(0.20)*(0.20)*(0.20)*(0.20)Use the same approach here, but now every question is being answered incorrectly.
(___)*(___)*(___)*(___)If the probability of getting any individual question correct is 0.20, then the probability of getting it wrong must be 0.80.
(___)*(___)*(___)*(___)If the probability of getting any individual question correct is 0.20, then the probability of getting it wrong must be 0.80.
(0.80)*(0.80)*(0.80)*(0.80)We’ll start with the same setup as for the previous two parts.
(___)*(___)*(___)*(___)We don’t care about the result to question 4. We could get it right or get it wrong, and it makes no difference to whether or not our even of interest occurs.
(___)*(___)*(___)*(___)We don’t care about the result to question 4. We could get it right or get it wrong, and it makes no difference to whether or not our even of interest occurs. Since, on the fourth question, our event of interest is “getting the question right or wrong”, the probability of that outcome is 100% (or 1), since no other outcome is possible.
(___)*(___)*(___)*(1)If the first question that we get right is question 3, what must have been the outcome for each of the first two questions?
(___)*(___)*(___)*(1)If the first question that we get right is question 3, what must have been the outcome for each of the first two questions? We must have gotten both of the first two questions wrong. The probability of getting any individual question wrong was 0.80.
(0.80)*(0.80)*(___)*(1)We must have gotten the third question right. The probability of guessing correctly was 0.20.
(0.80)*(0.80)*(0.20)*(1)Will the approach we’ve taken to each of the previous three questions work here? Why or why not?
(___)*(___)*(___)*(___)For a single question, what is the probability that you get that question correct?
What is the probability that you get every one of the questions correct?
What is the probability that you get every one of the questions wrong?
What is the probability that the first one you get wrong is question three?
What is the probability that you get exactly two questions right?
So in the last question, none of the choices were correct – but why? There are lots of ways that we could get two of the questions right. We could get the first two right, the first and last right, the middle two right, and more! We need to account for all of these possibilities.
Binomial Experiments and the Binomial Distribution
Binomial Experiments: A binomial experiment satisfies each of the following three criteria:
- There are \(n\) repeated trials.
- Each trial has two possible outcomes (usually called success and failure for convenience)
- The trials are independent of one another. That is, for each trial, the probability of success is \(p\) (which remains constant).
Binomial Distribution: Let \(X\) be the number of successes resulting from a binomial experiment with \(n\) trials. We can compute the following probabilities:
- The probability of exactly \(k\) successes is given by
\(\displaystyle{\mathbb{P}\left[X = k\right] = \binom{n}{k}\cdot p^k\left(1 - p\right)^{n-k} \approx \tt{dbinom(k, n, p)}}\) - The probability of at most \(k\) successes is given by
\(\displaystyle{\mathbb{P}\left[X \leq k\right] = \sum_{i=0}^{k}{\binom{n}{i}\cdot p^i\left(1 - p\right)^{n-i}} \approx \tt{pbinom(k, n, p)}}\)
In the equations above, \(\binom{n}{k} = \frac{n!}{k!\left(n-k\right)!}\) counts the number of ways to arrange the \(k\) successes amongst the \(n\) trials. That being said, the R functionality, dbinom() and pbinom() allow us to bypass the messy formulas – but you’ll still need to know what these functions do in order to use them correctly!
We need to use the binomial distribution to find probabilities associated with numbers of successful (or failing) outcomes in which we do not know for certain the trials on which the successes (or failures) occur.
The code block below is set up to find the probability of exactly two flips of a coin landing heads-up out of seven total flips. Edit the code block so that it finds the probability that you got exactly two of the four questions on your chemistry quiz from earlier correct. As a reminder, there were five answer options for each question and you were guessing randomly.
The arguments to dbinom() are, in order: the number of successful outcomes, the total number of trials, and the probability of a successful outcome on one trial.
You are interested in two successful outcomes, so the first argument doesn’t need changing. The other two will need to be updated.
For the second argument, how many questions are on the quiz?
dbinom(2, ___, ___)For the third argument, what is the probability of guessing correctly on a single question?
dbinom(2, 4, ___)Since each question has five possible choices, one of which is correct, the probability of a correct response on one question is 0.2.
dbinom(2, 4, 0.2)
dbinom(2, 4, 0.2)
dbinom(2, 4, 0.2)Good work. Now you’ll get to try a few more problems! As you work through the next set of questions, you may want to check out this example and solution. Note that in that document, I mention that drawing a simple picture for each problem will help you decide which function(s) you might use and whether you might need to make multiple computations. This is a really important strategy that will help you in developing a strategy to solve each problem.
Practice: For each of the following, consider a scenario in which a random sample of 18 students is asked (in private) whether they’ve failed to hand in at least one assignment this semester. We assume that about 34% of students fail to hand in at least one assignment.
- Given a single, randomly chosen student, what is the probability that the student will have failed to hand in at least one assignment this semester?
If we had 100 randomly chosen students, how many might you expect to have failed to hand in at least one assignment? How did you arrive at that number?
We might expect about 34 students out of 100 to have failed to hand in at least one assignment, since 34% of 100 is 34. The calculation you likely did in your head was 100 * 0.34.
The 0.34 you used in that calculation is the probability that a single, randomly selected student has failed to hand in at least one assignment.
0.34
0.34
0.34- Find the probability that exactly 7 of the 18 students have failed to hand in at least one assignment.
We don’t know exactly which of the 18 students are failing to hand in at least one assignment here. We’ll need a special function to account for the different combinations of students.
Which function is more appropriate — dbinom() or pbinom()?
We’ll use dbinom() since we want the probability of exactly seven students failing to hand in an assignment.
Fill in the blanks to calculate the desired probability.
dbinom(___, ___, ___)The first argument is the number of successes. If a “success” is a student having failed to hand in at least one assignment, how many successes are you interested in?
dbinom(___, ___, ___)We wanted exactly seven students to have failed to hand in at least one assignment. The second argument is the total number of trials — how many trials are being “run” here?
dbinom(7, ___, ___)There are 18 students total in our random sample, so there are 18 trials. The final argument is the probability of a “successful” outcome — what is the probability of a single student failing to hand in at least one assignment?
dbinom(7, 18, ___)dbinom(7, 18, 0.34)
dbinom(7, 18, 0.34)
dbinom(7, 18, 0.34)- Find the probability that at most 9 of the 18 students have failed to hand in at least one assignment.
Similar to the previous question, we don’t know exactly which of the students are failing to hand in at least one assignment here. We’ll need a special function to account for the different combinations of students.
Which function is more appropriate — dbinom() or pbinom()?
We’ll use pbinom() since we want the probability of at most nine students failing to hand in an assignment.
Fill in the blanks to calculate the desired probability.
pbinom(___, ___, ___)The number of trials and the probability of a “success” haven’t changed — fill them in.
pbinom(___, 18, 0.34)For pbinom(), the first argument is the maximum number of successes you are willing to consider. If a “success” is a student having failed to hand in at least one assignment, what is the maximum number of successes you are interested in?
pbinom(___, 18, 0.34)pbinom(9, 18, 0.34)
pbinom(9, 18, 0.34)
pbinom(9, 18, 0.34)- Find the probability that at least 11 of the 18 students have failed to hand in at least one assignment.
Again, we’ll need a special function because we don’t know which of the 18 students will have failed to hand in an assignment.
Unfortunately, neither dbinom() nor pbinom() is a perfect fit for this scenario. Is either one better-suited to it?
pbinom() can handle multiple possible outcomes, while dbinom() is most useful when we are interested in exactly one outcome.
Is there a way to use pbinom() here, even though it computes “at most” probabilities and we want “at least”?
The challenge is that pbinom() finds the probability of at most some number of successes, not the probability of at least some number of successes.
The call below is a start, but something is wrong with it. What?
pbinom(11, 18, 0.34)This call calculates the probability of 0 through 11 successes. That’s not what we want. Could we start with the probability of all possible outcomes and then remove the ones we don’t want?
pbinom(11, 18, 0.34)What is the probability that somewhere between 0 and 18 students (inclusive) fail to hand in at least one assignment?
Since we only have 18 students, it must be the case that somewhere between 0 and 18 students fail to hand in at least one assignment — nothing else is possible. This probability is 1 (or 100%).
Fill in the blanks.
1 - pbinom(___, ___, ___)Something is wrong with the attempt below. What needs to be fixed?
1 - pbinom(11, 18, 0.34)That call removes the probability of at most 11 students failing to hand in at least one assignment, leaving only the probability of at least 12 — but we wanted at least 11. Fix the first argument.
1 - pbinom(___, 18, 0.34)1 - pbinom(10, 18, 0.34)
1 - pbinom(10, 18, 0.34)
1 - pbinom(10, 18, 0.34)- Find the probability that between a minimum of 6 and a maximum of 12 out of the 18 students have failed to hand in at least one assignment.
Similar to the previous question, neither dbinom() nor pbinom() is a perfect fit here. We should prefer pbinom() though, since we are interested in a collection of outcomes rather than exactly a single outcome.
The strategy from the previous question won’t work exactly here either. Maybe we can use a similar idea though!
Which of the following corresponds to a probability that is definitely too large?
pbinom(6, 18, 0.34)
pbinom(12, 18, 0.34)The result of the call below is larger than what we want because it includes all outcomes we care about plus some extra ones. Can we subtract something to remove the unwanted outcomes?
pbinom(12, 18, 0.34)Fill in the blanks.
pbinom(12, 18, 0.34) - ___(___, 18, 0.34)How many events do we need to remove the probability of — exactly one event, or a collection of events?
pbinom(12, 18, 0.34) - ___(___, 18, 0.34)Since we need to remove a collection, let’s use pbinom() again. Think carefully about which events we need to remove. What number goes in the blank?
pbinom(12, 18, 0.34) - pbinom(___, 18, 0.34)The code below is wrong — why?
pbinom(12, 18, 0.34) - pbinom(6, 18, 0.34)That leaves us with the probability of 7, 8, …, up to 12 students failing to hand in an assignment. That’s not quite right — we wanted to include 6 as well.
pbinom(12, 18, 0.34) - pbinom(6, 18, 0.34)pbinom(12, 18, 0.34) - pbinom(5, 18, 0.34)
pbinom(12, 18, 0.34) - pbinom(5, 18, 0.34)
pbinom(12, 18, 0.34) - pbinom(5, 18, 0.34)In several of the previous scenarios, we needed to think about the correct “first argument” being passed to pbinom(). Don’t try to memorize when to subtract one, when to add one, when to leave the number the same as it appeared in the problem, etc. The language is what matters, and there are lots of ways to express which outcomes we are most interested in. If you insist on memorizing, you’ll become frustrated quickly.
Instead of memorizing, take the time to draw a picture to help you. Examples of what these pictures might look like can be seen in the example and solution document, which I pointed you to earlier.
- The expected number of successes in a binomial experiment is sometimes denoted by \(\mathbb{E}\left[X\right]\) and can be computed as \(\mathbb{E}\left[X\right] = n\cdot p\), where \(n\) denotes the number of trials run and \(p\) denotes the probability of success on a single trial. Sometimes it is convenient to think of the expected number of successes as “the mean”. Use the code block below to compute the expected number of students who have failed to hand in at least one assignment:
Use the formula \(n \cdot p\) from the problem statement to compute the expected value.
\(n\) stands for the number of trials. How many trials are there here?
\(p\) stands for the probability of success on a single trial. Here “success” is a student failing to hand in at least one assignment. What is the value of \(p\)?
18 * 0.34
18*0.34
18*0.34- The standard deviation in the number of successes for a binomial experiment can also be computed. The quantity \(\displaystyle{s_X = \sqrt{n\cdot p\left(1 - p\right)}}\), where \(n\) denotes the number of trials run and \(p\) denotes the probability of success on a single trial, is the standard deviation in number of successes. Use the code block below to compute the standard deviation in number of students who have failed to hand in at least one assignment from random samples of 18 students:
Use the formula from the problem statement to compute the answer.
You can compute the square root in R using the sqrt() function.
\(n\) is still the number of trials and \(p\) is still the probability of a student failing to hand in at least one assignment.
Fill in the blanks.
sqrt(___ * ___ * (1 - ___))sqrt(18 * 0.34 * (1 - 0.34))
sqrt(18*0.34*(1 - 0.34))
sqrt(18*0.34*(1 - 0.34))Be sure to write down what questions you had as you worked through these problems and to have a teacher, colleague, or tutor help clarify things for you.
Submit
If you are part of a course with an instructor who is grading your work on these activities, please copy and submit both of the hashes below using the method your instructor has requested.
The hash below encodes your responses to the multiple choice questions in this activity.
Click the button below to generate your exercise submission code. This hash encodes your work on the graded code exercises in this activity.
You must have attempted the graded exercises before clicking — clicking generates a snapshot of your current results. If you have completed the activity over multiple sessions, please go back through and hit the Run Code button on each graded exercise before generating the hash below, to ensure your most recent results are recorded.
Summary
- The probability of an event \(A\) is a measure of its likelihood and is denoted \(\mathbb{P}[A]\). Every probability must be between 0 and 1.
- If \(A\) and \(B\) are independent events, then \(\mathbb{P}[A \text{ and } B] = \mathbb{P}[A] \cdot \mathbb{P}[B]\).
- A binomial experiment satisfies: (1) \(n\) repeated trials, (2) each trial has two possible outcomes, and (3) trials are independent with constant probability of success \(p\).
- If \(X\) counts successes in a binomial experiment with \(n\) trials and success probability \(p\):
- \(\mathbb{P}[X = k] \approx\)
dbinom(k, n, p)— for exactly \(k\) successes - \(\mathbb{P}[X \leq k] \approx\)
pbinom(k, n, p)— for at most \(k\) successes - Draw a picture to help you see how to use
pbinom()and/ordbinom()to calculate probabilities. These two functions above are sufficient to handle any binomial probability scenario — the challenge is identifying how to combine them.
- \(\mathbb{P}[X = k] \approx\)
- The expected number of successes is \(\mathbb{E}[X] = n \cdot p\).
- The standard deviation of number of successes is \(s_X = \sqrt{n \cdot p \cdot (1 - p)}\).
The next activity introduces the normal distribution — a continuous probability distribution that underpins much of classical statistical inference. Our focus will be on learning to compute probabilities and percentiles from this important distribution.