Introduction
Welcome back! In our last lesson, we explored conditional probability and Bayes' theorem, which gave us a powerful framework for updating our beliefs about events in light of new evidence. We reasoned about outcomes like "a test is positive" or "an email is spam."
However, to build sophisticated AI models, especially for tasks like prediction, we need to work with numerical outcomes. For example, predicting the price of a stock, the temperature tomorrow, or the number of users who will click an ad. These numerical outcomes of random phenomena are called random variables.
In this lesson, you will learn to distinguish between discrete and continuous random variables and their distributions. Understanding this distinction is fundamental because the mathematical tools we use to describe and model these two types of variables are different. This forms the bedrock for understanding probability distributions, which are the heart of probabilistic AI models.
1. The Fundamental Distinction: Counting vs. Measuring
At its core, the difference between discrete and continuous random variables is the difference between counting and measuring.
- Discrete random variables are typically the result of counting. They can only take on a finite or countably infinite number of distinct values. There are "gaps" between the possible values.
- Continuous random variables are typically the result of measuring. They can take on any value within a given range. There are no gaps between the possible values; between any two values, there is always another possible value.
To build a strong intuition for this, let's watch a video that explores this distinction with several clear examples.
Discrete and continuous random variables | Probability and Statistics | Khan Academy
This video from Khan Academy provides an excellent conceptual overview of discrete and continuous random variables. Pay close attention to the examples used and the reasoning for classifying each one.
Watch the entire video. Focus on the core idea of 'distinct or separate values' for discrete variables versus 'any value in an interval' for continuous variables. Notice how a continuous quantity like time can become discrete if we round it.
As the video highlighted, think about these key questions when classifying a random variable:
- Can I list all the possible outcomes, even if that list is infinite? (e.g., 0, 1, 2, 3, ...). If yes, it's discrete.
- Does the variable represent a measurement that could be infinitely precise, taking any value in a range? (e.g., height, weight, time). If yes, it's continuous.
2. Describing Distributions: PMF, PDF, and CDF
Now that we can distinguish between the two types of variables, how do we describe their associated probabilities? For example, how do we state the probability of a fair die landing on '3' versus the probability of a person's height being exactly 175cm? The approaches are fundamentally different.
This brings us to the concept of probability distributions, which are functions that describe the likelihood of a random variable taking on certain values.
Probability Distribution Functions (PMF, PDF, CDF)
The following video from zedstatistics introduces the three key functions used to describe probability distributions: the Probability Mass Function (PMF), the Probability Density Function (PDF), and the Cumulative Distribution Function (CDF).
Watch the video from the beginning until 15:35. Focus on how each function is defined and visualized for both discrete (dice roll) and continuous (women's height) examples. Since you have a calculus background, pay special attention to the relationship between the PDF and CDF, described in terms of gradient (derivative) and area (integral).
Let's summarize the key functions from the video:
-
Probability Mass Function (PMF):
- Used for discrete random variables.
- Assigns a specific probability to each possible value. For a random variable , the PMF gives .
- The sum of all probabilities in a PMF must equal 1.
- Example: For a fair six-sided die, the PMF would be for .
-
Probability Density Function (PDF):
- Used for continuous random variables.
- The value of the PDF at a point, , is not a probability. It represents a "probability density."
- Probabilities are found by calculating the area under the curve of the PDF over an interval. The probability of falling between and is .
- This implies that the probability of a continuous random variable being exactly a specific value is zero: . This is a crucial, though sometimes counter-intuitive, point.
- The total area under the entire PDF curve must equal 1.
-
Cumulative Distribution Function (CDF):
- Can be used for both discrete and continuous random variables.
- It gives the cumulative probability of the random variable being less than or equal to a value . That is, .
- For a discrete variable, the CDF is a step function.
- For a continuous variable, the CDF is a smooth, non-decreasing function that goes from 0 to 1.
The connection to calculus is powerful: the PDF is the derivative of the CDF, and the CDF is the integral of the PDF. This gives you a formal way to move between these two representations.
3. Formalizing the Concepts
The videos provided a great intuitive and visual understanding. Now, let's solidify these ideas with more formal definitions, which are essential for applying these concepts rigorously in AI and machine learning.
Lesson 33 Continuous Random Variables | Introduction to Probability
This text, 'Lesson 33: Continuous Random Variables' from an online probability course, provides a more mathematical treatment of the topics we've just discussed.
Read the sections titled 'Theory' and 'Essential Practice' (you don't need to solve the practice problems, just read through them to see how the concepts are applied). Focus on Definition 33.1 (defining a continuous RV via its CDF), the explanation for why P(X=x)=0, and Definition 33.2 (defining the PDF as the derivative of the CDF).
This reading reinforces the key ideas we've covered. The probability of a continuous random variable taking on any single, exact value is zero because there are infinitely many possible values. Think of it like a dart hitting a board, as described in the textbook Dive into Deep Learning. The chance of hitting a single mathematical point is zero; you can only talk about the probability of hitting a certain area. Similarly, for a continuous random variable, we can only talk about the probability of it falling within a certain interval.
4. Summary Table
To consolidate your understanding, here is a helpful table that summarizes the key distinctions between discrete and continuous random variables.

Conclusion
In this lesson, you've learned the critical distinction between discrete and continuous random variables and how their probability distributions are described. This is not just a theoretical exercise; choosing the correct type of distribution is a fundamental step in building probabilistic models in AI. For example, a model predicting customer churn (a yes/no outcome) would use a discrete distribution, while a model predicting house prices would use a continuous one.
Key Takeaways:
- Discrete Random Variables are countable (e.g., number of coin flips) and are described by a Probability Mass Function (PMF), which gives the probability at each distinct point.
- Continuous Random Variables are measurable (e.g., height, time) and are described by a Probability Density Function (PDF), where probability is the area under the curve over an interval.
- For any continuous variable , the probability of it taking an exact value is zero, i.e., .
- The Cumulative Distribution Function (CDF), , is a unifying concept that applies to both types of variables and represents the total accumulated probability up to a value .
Preview of the Next Lesson:
Simply knowing the distribution of a variable isn't always enough. We often want to summarize its main characteristics in just a few numbers. In the next lesson, you will learn how to compute and interpret mean, variance, and standard deviation for a dataset. We will see how the calculation of these summary statistics depends on whether the variable is discrete or continuous, building directly on the foundations you've established today.