dbinom(2, size = 3, prob = 0.1)[1] 0.027
BIOS 600 - Spring 2026
Lab 3 due Friday at 11:59pm.
HW 2 due Thursday at 11:59pm.
Participation activity due Friday at 11:59pm on Canvas (ungraded but you’ll get feedback). There will be time to work on this in class on Thursday.
What is a random variable?
Discrete distributions, Binomial and Poisson, and applications
A random variable is a quantity whose value depends on the outcome of a random event.
Traditionally, we use capital letters \(X\), \(Y\), \(Z\) to denote random variables.
The values that random variables take are in lowercase \(x\), \(y\), \(z\)
So, the probability that random variable \(X\) has the value \(x\) is denoted by \(P(X = x)\)
Random variables encountered in this class will be either discrete or continuous.
Discrete random variables are those that can take on a countable number of potential values (could be countably infinite!), each associated with a probability of occurring.
This list of possible values and probabilities is the probability distribution for the discrete random variable in question.
Probability distributions let us investigate how likely events may be.
For discrete random variables, you may also see the term probability mass function, which is the same thing.
Let \(X\) be the random variable for birth status in the US. Its probability distribution may be given by
| Event | Probability |
|---|---|
| X = pre | 0.10 |
| X = early | 0.27 |
| X = full | 0.57 |
| X = late/post | 0.06 |
| Event | Probability |
|---|---|
| X = pre | 0.10 |
| X = early | 0.27 |
| X = full | 0.57 |
| X = late/post | 0.06 |
There are three rules for discrete probability distributions:
Let’s verify the three rules above are satisfied with the births example.
Some “types” of random variables come up very often. Consider a dichotomous (two-level) random variable \(X\):
This is known as a Bernoulli random variable, and has a probability of “success” denoted by \(p\).
With the notation that event \(X=1\) is a “success” and \(X=0\) is a “failure”, \(P(X=1)=p\) and \(P(X=0) = 1-p\)
| Event | P(Event) |
|---|---|
| \(X=1\) | 0.5 |
| \(X=0\) | 0.5 |
| Event | P(Event) |
|---|---|
| \(X=1\) | 0.1 |
| \(X=0\) | 0.9 |
A “success” is not necessarily positive - if we are interested in the probability of dying, a “success” would be death.
Suppose we randomly select two independent US births in 2018, and \(Z\) is a new random variable that represents the number of preterm births among them.
\(Z\) can be 0, 1, or 2:
| 1st Birth \(X\) | 2nd Birth \(X\) | # Preterm Births \(Z\) | Probability of Outcome |
|---|---|---|---|
| 0 | 0 | 0 | |
| 1 | 0 | 1 | |
| 0 | 1 | 1 | |
| 1 | 1 | 2 |
Let \(X_1\) be 1 if the first birth is preterm, and \(X_2\) be 1 if the second birth is preterm, and 0 otherwise.
Because these two births are independent, then
\[ \begin{aligned} P(\textrm{both preterm}) &= P(\textrm{first preterm and 2nd preterm})\\ &= P(\textrm{first preterm}) \cdot P(\textrm{2nd preterm})\\ &= p * p = 0.1 \times 0.1 = 0.01 \end{aligned} \]
Back to the table, row 1 is given by
\(P(X_1 = 0 \cap X_2 = 0) = P(X_1 = 0) P(X_2 = 0) = (1-p)(1-p)\)
| 1st Birth \(X\) | 2nd Birth \(X\) | # Preterm Births \(Z\) | Probability of Outcome |
|---|---|---|---|
| 0 | 0 | 0 | (0.9)(0.9)=0.81 |
| 1 | 0 | 1 | |
| 0 | 1 | 1 | |
| 1 | 1 | 2 |
Thus, the probability distribution of the number of preterm births out of two independent births is given by
| \(z=0\) | \(z=1\) | \(z=2\) | |
|---|---|---|---|
| \(P(Z=z)\) | 0.81 | 0.18 | 0.01 |
Now let \(Z\) be the random variable corresponding to the number of preterm births among 3 independently sampled births
| First Birth \(X_1\) | Second Birth \(X_2\) | Third Birth \(X_3\) | Number of Preterm Births \(Z\) | Probability |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 1 | 0 | 0 | 1 | |
| 0 | 1 | 0 | 1 | |
| 0 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 2 | |
| 1 | 0 | 1 | 2 | |
| 0 | 1 | 1 | 2 | |
| 1 | 1 | 1 | 3 |
Row 1 is given by
\(P(X_1 = 0 \cap X_2 = 0 \cap X_3 = 0) = (1-p)(1-p)(1-p)\)
| First Birth \(X_1\) | Second Birth \(X_2\) | Third Birth \(X_3\) | Number of Preterm Births \(Z\) | Probability |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0.729 |
| 1 | 0 | 0 | 1 | |
| 0 | 1 | 0 | 1 | |
| 0 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 2 | |
| 1 | 0 | 1 | 2 | |
| 0 | 1 | 1 | 2 | |
| 1 | 1 | 1 | 3 |
Row 2 is given by
\(P(X_1 = 1 \cap X_2 = 0 \cap X_3 = 0) = p(1-p)(1-p)\)
| First Birth \(X_1\) | Second Birth \(X_2\) | Third Birth \(X_3\) | Number of Preterm Births \(Z\) | Probability |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0.729 |
| 1 | 0 | 0 | 1 | 0.081 |
| 0 | 1 | 0 | 1 | |
| 0 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 2 | |
| 1 | 0 | 1 | 2 | |
| 0 | 1 | 1 | 2 | |
| 1 | 1 | 1 | 3 |
…et cetera
| First Birth \(X_1\) | Second Birth \(X_2\) | Third Birth \(X_3\) | Number of Preterm Births \(Z\) | Probability |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0.729 |
| 1 | 0 | 0 | 1 | 0.081 |
| 0 | 1 | 0 | 1 | 0.081 |
| 0 | 0 | 1 | 1 | 0.081 |
| 1 | 1 | 0 | 2 | 0.009 |
| 1 | 0 | 1 | 2 | 0.009 |
| 0 | 1 | 1 | 2 | 0.009 |
| 1 | 1 | 1 | 3 | 0.001 |
If we randomly sample 3 births, what is the chance 2 are preterm?
0.009 + 0.009 + 0.009 = 0.027 (why?)
| First Birth \(X_1\) | Second Birth \(X_2\) | Third Birth \(X_3\) | Number of Preterm Births \(Z\) | Probability |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0.729 |
| 1 | 0 | 0 | 1 | 0.081 |
| 0 | 1 | 0 | 1 | 0.081 |
| 0 | 0 | 1 | 1 | 0.081 |
| 1 | 1 | 0 | 2 | 0.009 |
| 1 | 0 | 1 | 2 | 0.009 |
| 0 | 1 | 1 | 2 | 0.009 |
| 1 | 1 | 1 | 3 | 0.001 |
Thus, the probability distribution of the number of preterm births out of three independent births is given by
| \(z=0\) | \(z=1\) | \(z=2\) | \(z=3\) | |
|---|---|---|---|---|
| \(P(Z=z)\) | 0.729 | 0.243 | 0.027 | 0.001 |
Are these disjoint events, with probabilities in [0,1], that all sum to 1?)
If we randomly sample 4 births, what is the probability distribution for the number of preterm births?
To build a similar table would start to become egregious.
Luckily, there is a formula for this probability distribution!
The binomial distribution gives the probability of \(k\) “successes” from a sequence of \(n\) independent Bernoulli trials. There are three assumptions:
There is a fixed number of trials \(n\), each of which is a Bernoulli random variable.
The outcomes of the \(n\) trials are independent.
The probability of success, \(p\), is the same of each of these trials.
If \(X\) has a binomial distribution, then
\[P(X=k) = {n \choose k}p^k (1-p)^{n-k}\]
What do these components mean?
This expression will always be provided to you if needed.
If we randomly sample 3 births, what is the chance 2 are preterm?
There is a fixed number of trials, each of which is a Bernoulli random variable
The outcomes of the trials are independent
The probability of success is the same for each of these trials
Thus, \(Z \sim Binom(3, 0.1)\).
\[ \begin{aligned} P(Z=2) &= {3 \choose 2} 0.1^2 (1-0.1)^{3-2} \\ &= \frac{3!}{2!(3-2)!} \times 0.1^2 \times 0.9 ^1 = 0.027 \end{aligned} \]
We can calculate these probabilities in R with the dbinom() function:
For today’s participation, you’ll practice some of the functions we learn today using R.
On the course website, download the Quarto template for the Application Exercise for today. Save the file with a sensible name (ae-01.qmd) in your project folder.
Begin by working on Exercises 1 and 2.
Discrete distribution taking on possible values 0, 1, 2, \(\ldots\), \(\infty\)
Often used to model counts or rare events
Much like the binomial distribution, requires a few assumptions
The Poisson distribution gives the probability that \(k\) events occur in a given “interval”. There are four assumptions:
Within any interval, \(k\) may take on values 0, 1, 2, 3, \(\ldots\), \(\infty\)
Each event occurs independently, both within the same interval, and between intervals
The average rate at which events occur in an interval, \(\lambda\), is constant
Two events cannot occur simultaneously
What is an “interval”?
If \(X\) has a Poisson distribution, then
\[P(X=k) = \frac{\lambda^k e^{-\lambda}}{k!}\]
What do these components mean?
This expression will always be provided to you if needed.
Suppose on average, there are 1.5 deaths due to Alzheimer’s Disease in a town each year. For a one-year period in this town, what is the chance that two or more people die from Alzheimer’s?
Within any interval, the number of AD deaths can range from 0 to \(\infty\) (technically not true, but close enough)
One individual dying of Alzheimer’s does not affect the chance of another person dying of Alzheimer’s
The AD death rate is constant in this town
Two AD deaths cannot occur at the same time (we can always subdivide time intervals such that only one person experiences this event in a given sub-interval)
Thus \(Z \sim Pois(1.5)\), and \(P(Z=0)\), \(P(Z=1)\), and \(P(Z\geq 2)\) are disjoint events. So, \(P(Z \geq 2) = 1- [P(Z = 0) + P(Z = 1)]\), where
\[ \begin{aligned} P(Z=0) &= \frac{1.5^0 \times e^{-1.5}}{0!}\approx 0.223 \\ P(Z=1) &= \frac{1.5^1 \times e^{-1.5}}{1!}\approx 0.335 \end{aligned} \]
And so \(P(Z \geq 2) \approx 1-0.223-0.335 = 0.442\).
We can calculate these values in R using the dpois() function:
Note: Each parentheses needs a buddy! Common source of Quarto files not rendering…
If we wanted to abbreviate our typing (and reduce possibility of typos), we can save our first two probabilities as objects p0 and p1 to use them later.
Suppose we have a count random variable that follows a Poisson distribution:
Since each event is independent of others and the rate \(\lambda\) is constant, the probability that an event occurs within an interval is proportional to the length of that interval.
E.g., we would expect twice the number of events to occur in an interval of twice the length; we would expect 1/9 times the number of events to occur in an interval 9 times as small; and so on.
Suppose on average, there are 1.5 deaths due to Alzheimer’s disease in a town each year.
What is the average one-month rate of deaths due to Alzheimer’s disease in this town?
For any given one-month period in this town, what is the probability that exactly one person dies from Alzheimer’s? (Just the expression is fine)
For \(X \sim Pois(\lambda)\),
\[P(X=k) = \frac{\lambda^k e^{-\lambda}}{k!}\]
In today’s participation, continue with Exercise 3.
When you’ve completed the exercises, render, save to PDF, and submit on Canvas> Assignments. Due Wednesday at 11:59pm.
Now that we’ve defined random variables and explored a few distributions, we might be interested in some other aspects of their distributions.
Suppose we are interested in the probability distribution corresponding to the number of preterm births in a random sample of five independent US births.
How many preterm births should we expect?
How “spread out” would this distribution be?
The expected value of a discrete random variable \(X\) is a weighted average of the possible outcomes:
\[E(X) = \sum_{\textrm{all } x} x \cdot P(X = x)\]
This is a property of the distribution of \(X\), not of the random variable itself.
Example: Let Z be a coin toss. \(Z \sim Bern(.5)\). \(E(Z) = .5\) and \(Var(Z) = 0.5 \cdot (0.5) = 0.25\).
For \(Z \sim Binom(n, p)\), \(E(Z) = np\) and \(Var(Z) = np(1-p)\)
For \(Z \sim Pois(\lambda)\), \(E(Z) = Var(Z) = \lambda\)
Discrete random variables
Binomial, Poisson random variables and applications
Expected values and variances