5.1: Random Variables- Discrete and Continuous
- Page ID
- 58903
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)In earlier chapters, we explored types of data, in particular, categorical vs. quantitative, and discrete vs. continuous variables. We will connect these qualities of variables with notions of probability in this chapter.
Definition: Random Variable
A random variable is a quantitative variable whose value is determined by a random event.
We usually represent random variables with an uppercase letter like X or Y. For example:
- Let X = number of heads after flipping 3 coins
- Let Y = the waiting time (in minutes) until a bus arrives
The word “random” here just means that we don’t know what value the variable will take before we observe the outcome, it depends on chance. Other terminology you may encounter to describe this is non-deterministic or stochastic.
Some non-examples of random variables could include:
- A person's favorite food. Although we cannot predict this, it is not a quantitative variable.
- The freezing temperature of pure water at sea-level (0° C). This is a measurable and quantitative variable, but is not due to chance. It's a fixed value that is a property of nature. In fact the celsius temperature scale was originally based on this measurable temperature!
- Population parameters. For example, the average height of every single person on earth. This is a fixed value that we could theoretically calculate. However, it's feasibly impossible to do so, so any attempt to measure it ultimately results in requiring a sample, which introduces randomness.
When we work with random variables, we’re combining the power of probability with data. We’re no longer just talking about events like rolling a die, but about the numerical outcome we could observe from that process.
Two Types of Random Variables
Just like with data earlier, we can divide random variables into two major types:
Discrete Random Variables
Take on separate, distinct values (usually whole numbers).
- Examples:
- X = number of students absent on a given day (0, 1, 2, …)
- Y = number of correct answers on a quiz
- Z = number of Atlantic hurricanes that make landfall in a season
- Usually represent things you can “count”
Continuous Random Variables
Can take on any value in an interval (there are infinite possibilities between any two values).
- Examples:
- X = the time (in seconds) it takes an athlete to run 100 meters
- Y = the height (in meters) of a randomly selected medical patient
- Z = the cost (in dollars) associated with a traffic accident
- Usually represent things you "measure"
Distributions
Every random variable has a certain set of outcomes it can take, and each of those outcomes comes with a probability. This is why we are interested in random variables. They allow for us to categorize and calculate probabilities associated with certain scenarios. We design a way to organize this information and call it a probability distribution.
Example
Suppose we flip two fair coins and count the number of heads. Let the random variable X denote this. There are 4 different outcomes to this experiment, listed below:
(H, H) : two heads
(H, T) : first coin heads, second coin tails (1 head)
(T, H) : first coin tails, second coin heads (1 head)
(T, T) : two tails (no heads)
If we imagine the possibilities for X, there are only 3. X can either be equal to 0, 1, or 2.
If we wanted to tabulate the probabilities of these occurrences, we only need count the number of events corresponding to each value that X can be. For example, there is only one way for X to be equal to 0. It must be the case that we flipped two tails, which has a 1 in 4 change. In contrast, there are two ways that X could end up equal to 1. Either (H, T) or (T, H). This gives us a 2 in 4 chance. The summary is given below using our notation from chapter 4. When we write \(P(X = x)\), this means the probability that our random variable has taken on a value of \(x\). If it is completely clear which random variable and context we are using, we might use the shorter notation \(P(x)\).
- \(P(X = 0) = 0.25\)
- \(P(X = 1) = 0.5\)
- \(P(X = 2) = 0.25\)
We can alternatively summarize this information in a table. We call this relationship that tells us the probability of each value the Probability Mass Function (PMF)
| \(x\) | \(P(X = x)\) |
|---|---|
| 0 | 0.25 |
| 1 | 0.5 |
| 2 | 0.25 |
Each column of the table stores the possible value for X in the top row, and its corresponding probability in the bottom row. Finally, we can also organize this information in a bar graph.

Check Your Understanding
Take a moment and sort the examples below as Discrete or Continuous random variables:
- 1. Number of books you check out at the library
- 2. The amount of rainfall in a day (in inches)
- 3. Number of people who show up for your group meeting
- 4. Temperature in degrees Fahrenheit at noon today
Discuss: Can we define a probability distribution for each of these? What would it look like?
Why This Matters
As we move forward into probability distributions, we’ll focus on two types:
- Discrete: starting with the binomial distribution
- Continuous: using the normal distribution
These tools let us assign probabilities to outcomes not just with logic or counting, but with a defined distribution that follows real-world patterns. And that’s powerful.
Project tie in
Choose one variable from your housing dataset. Could it be modeled as a random variable? If it's discrete, what values can it take on? If it's continuous, what units would you use?
Probability Distribution Definition
A probability distribution outlines how probabilities are distributed across all possible values of a random variable. If our random variable describes discrete data, we refer to its distribution as a discrete probability distribution. We saw an example of this above in the coin flips.
To be a valid discrete probability distribution, your table must meet these two rules:
- Each probability must be between 0 and 1 (inclusive):
→ \( 0 \leq P(X = x) \leq 1 \) - The sum of all probabilities must equal 1 (in the below example we have three values)
→ \( P(X = 0) + P(X = 1) + P(X = 2) = 1 \)
Take a second to verify these rules check out for the coin flip example above.
Realistic Examples
We have only discussed a simple example that is calculated from basic probability. But in reality, when we want to investigate meaningful and important ideas, our distributions can be extremely complicated! For example, how could we build a distribution that tells us the probability of the number of patients that an emergency room sees on a given day? Or the amount of produce a grocery store sells and therefore needs to order? We will start small and then work our way up, but there are two techniques we will investigate. The first is how we can use probabilistic models (the binomal distribution) to create more complicated ideas. The second goes back to our topic in the beginning of the course, that we can utilize descriptive statistics and data to inform probabilities.


