Cumulative Distribution Function
When we discussed discrete random variables, we introduced the concept of cumulative distribution functions (CDFs). One of the motivations was that if we view a PMF as a train of delta functions, they are technically not well-defined functions. However, it turns out that the CDF is always a well-defined function. In this section, we will complete the story by first discussing the CDF for continuous random variables. Then, we will come back and show you how the CDF can be derived for discrete random variables.
4.3.1CDF for continuous random variables
Let \(X\) be a continuous random variable with a sample space \(\Omega = \R\). The cumulative distribution function (CDF) of \(X\) is
The interpretation of the CDF can be seen from Figure 4.5. Given a PDF \(f_X\), the CDF \(F_X\) evaluated at \(x\) is the integration of \(f_X\) from \(-\infty\) up to a point \(x\). The integration of \(f_X\) from \(-\infty\) to \(x\) is nothing but the area under the curve of \(f_X\). Since \(f_X\) is non-negative, the larger the value \(x\) at which we evaluate \(F_X(x)\), the more area under the curve we are looking at. In the extreme when \(x = -\infty\), we can see that \(F_X(-\infty) = 0\), and when \(x = +\infty\) we have that \(F_X(+\infty) = \int_{-\infty}^{\infty} f_X(x) \;dx = 1\).

(Uniform random variable) Let \(X\) be a continuous random variable with PDF \(f_X(x) = \frac{1}{b-a}\) for \(a \le x \le b\), and is 0 otherwise. Find the CDF of \(X\).
The CDF of \(X\) is given by
As you can see from this practice exercise, we explicitly break the CDF into three segments. The first segment gives \(F_X(x) = 0\) because for any \(x \le a\), there is nothing to integrate, since \(f_X(x)=0\) for any \(x \le a\). Similarly, for the last segment, \(F_X(x) = 1\) for all \(x > b\) because once \(x\) goes beyond \(b\), the integration will cover all the non-zeros of \(f_X\). Figure 4.6 illustrates the PDF and CDF for this example.

In MATLAB, we can generate the PDF and CDF using the commands pdf and cdf respectively. For the particular example shown in Figure 4.6, the following code can be used. A similar set of commands can be implemented in Python.
% MATLAB code to generate the PDF and CDF
unif = makedist('Uniform','lower',-3,'upper',4);
x = linspace(-5, 10, 1500)';
f = pdf(unif, x);
F = cdf(unif, x);
figure(1); plot(x, f, 'LineWidth', 6);
figure(2); plot(x, F, 'LineWidth', 6);# Python code to generate the PDF and CDF
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
x = np.linspace(-5,10,1500)
f = stats.uniform.pdf(x,-3,4)
F = stats.uniform.cdf(x,-3,4)
plt.plot(x,f); plt.show()
plt.plot(x,F); plt.show()(Exponential random variable) Let \(X\) be a continuous random variable with PDF \(f_X(x) = \lambda e^{-\lambda x}\) for \(x \ge 0\), and 0 otherwise. Find the CDF of \(X\).
Clearly, for \(x < 0\), we have \(F_X(x) = 0\). For \(x \ge 0\), we can show that
Therefore, the complete CDF is (see Figure 4.7 for illustration):

The MATLAB code and Python code to generate this figure are shown below.
% MATLAB code to generate the PDF and CDF
pd = makedist('exp',2);
x = linspace(-5, 10, 1500)';
f = pdf(pd, x);
F = cdf(pd, x);
figure(1); plot(x, f, 'LineWidth', 6);
figure(2); plot(x, F, 'LineWidth', 6);# Python code to generate the PDF and CDF
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
x = np.linspace(-5,10,1500)
f = stats.expon.pdf(x,2)
F = stats.expon.cdf(x,2)
plt.plot(x,f); plt.show()
plt.plot(x,F); plt.show()4.3.2Properties of CDF
Let us now describe the properties of a CDF. If we compare these with those for the discrete cases, we see that the continuous cases simply replace the summations by integrations. Therefore, we should expect to inherit most of the properties from the discrete cases.
Let \(X\) be a random variable (either continuous or discrete), then the CDF of \(X\) has the following properties:
- (i) The CDF is nondecreasing.
- (ii) The maximum of the CDF is when \(x = \infty\): \(F_X(+\infty) = 1\).
- (iii) The minimum of the CDF is when \(x = -\infty\): \(F_X(-\infty) = 0\).
Proof. For (i), we notice that \(F_X(x) = \int_{-\infty}^{x} f_X(x')\;dx'\). Therefore, if \(s \le t\) then
Thus it shows that \(F_X\) is nondecreasing. (It does not need to be increasing because a CDF can have a steady state.) For (ii) and (iii), we can show that
We can show that the CDF we derived for the uniform random variable satisfies these three properties. To see this, we note that
The derivative of this function \(F_X'(x) = \frac{1}{b-a} > 0\) for \(a \le x \le b\). Also, note that \(F_X(x) = 0\) for \(x < a\) and \(x > b\), so \(F_X\) is nondecreasing. The other two properties follow because if \(x = b\), then \(F_X(b) = 1\), and if \(x = a\) then \(F_X(a) = 0\). Together with the nondecreasing property, we show (ii) and (iii).
Let \(X\) be a continuous random variable. If the CDF \(F_X\) is continuous at any \(a \le x \le b\), then
Proof. The proof follows from the definition of the CDF, which states that
This result provides a very handy tool for calculating the probability of an event \(a\le X\le b\) using the CDF. It says that \(\Pb[a \le X \le b]\) is the difference between \(F_X(b)\) and \(F_X(a)\). So, if we are given \(F_X\), calculating the probability of \(a \le X \le b\) just involves evaluating the CDF at \(a\) and \(b\). The result also shows that for a continuous random variable \(X\), \(\Pb[X = x_0] = F_X(x_0) - F_X(x_0) = 0\). This is consistent with our arguments from the measure's point of view.
(Exponential random variable) We showed that the exponential random variable \(X\) with a PDF \(f_X(x) = \lambda e^{-\lambda x}\) for \(x \ge 0\) (and \(f_X(x) = 0\) for \(x<0\)) has a CDF given by \(F_X(x) = 1-e^{-\lambda x}\) for \(x \ge 0\). Suppose we want to calculate the probability \(\Pb[1 \le X \le 3]\). Then the PDF approach gives us
If we take the CDF approach, we can show that
which yields the same as the PDF approach.
Let \(X\) be a random variable with PDF \(f_X(x) = 2x\) for \(0 \le x \le 1\), and is 0 otherwise. We can show that the CDF is
Therefore, to compute the probability \(\Pb[1/3 \le X \le 1/2]\), we have
A CDF can be used for both continuous and discrete random variables. However, before we can do that, we need a tool to handle the discontinuities. The following definition is a summary of the three types of continuity.
A function \(F_X(x)\) is said to be
- sep0ex
- Left-continuous at \(x = b\) if \(F_X(b) = F_X(b^-) \bydef \lim_{h \rightarrow 0} F_X(b-h)\);
- Right-continuous at \(x = b\) if \(F_X(b) = F_X(b^+) \bydef \lim_{h \rightarrow 0} F_X(b+h)\);
Continuous at \(x = b\) if it is both right-continuous and left-continuous at \(x =b\). In this case, we have $$\lim_{h \rightarrow 0} F_X(b-h) = \lim_{h \rightarrow 0} F_X(b+h) = F(b).$$
In this definition, the step size \(h > 0\) is shrinking to zero. The point \(b - h\) stays at the left of \(b\), and \(b+h\) stays at the right of \(b\). Thus, if we set the limit \(h \rightarrow 0\), \(b-h\) will approach a point \(b^-\) whereas \(b+h\) will approach a point \(b^+\). If it happens that \(F_X(b^-) = F_X(b)\) then we say that \(F_X\) is left-continuous at \(b\). If \(F_X(b^+) = F_X(b)\) then we say that \(F_X\) is right-continuous at \(b\). These are summarized in Figure 4.8.

Whenever \(F_X\) has a discontinuous point, it can be left-continuous, right-continuous, or neither. (“Neither” happens if \(F_X(b)\) takes a value other than \(F_X(b^+)\) or \(F_X(b^-)\). You can always create a nasty function that satisfies this condition.) For continuous functions, it is necessary that \(F_X(b^-) = F_X(b^+)\). If this happens, there is no gap between the two points.
For any random variable \(X\) (discrete or continuous), \(F_X(x)\) is always right-continuous. That is,
Right-continuous means that if \(F_X(x)\) is piecewise, it must have a solid left end and an empty right end. Figure fig:ch4_continuous_example shows an example of a valid CDF and an invalid CDF.

The reason why \(F_X\) is always right-continuous is that the inequality \(X \le x\) has a closed right-hand limit. Imagine the following situation: A discrete random variable \(X\) has four states: \(1,2,3,4\). Then,
Similarly, if you have a continuous random variable \(X\) with a PDF \(f_X\), then
In other words, the “\(\le\)” ensures that the rightmost state is included. If we defined CDF using \(<\), we would have gotten left-continuous, but this would be inconvenient because the \(<\) requires us to deal with limits whenever we evaluate \(X < x\).
For any random variable \(X\) (discrete or continuous), \(\Pb[X = b]\) is
This proposition states that when \(F_X(x)\) is discontinuous at \(x = b\), then \(\Pb[X = b]\) is the difference between \(F_X(b)\) and the limit from the left. In other words, the height of the gap determines the probability at the discontinuity. If \(F_X(x)\) is continuous at \(x = b\), then \(F_X(b) = \lim_{h\rightarrow 0} F_X(b-h)\) and so \(\Pb[X = b] = 0.\)

Consider a random variable \(X\) with a PDF
The CDF \(F_X(x)\) will consist of a few segments. The first segment is \(0 \le x < 1\). We can show that
The second segment is when \(1 \le x < 3\). Since there is no new \(f_X\) to integrate, the CDF stays at \(F_X(x) = F_X(1) = \frac{1}{2}\) for \(1 \le x < 3\). The third segment is \(x > 3\). Because this range has covered the entire sample space, we have \(F_X(x) = 1\) for \(x > 3\). How about \(x = 3\)? We can show that
Therefore, to summarize, the CDF is
A graphical illustration is shown in Figure 4.11.

4.3.3Retrieving PDF from CDF
Thus far, we have only seen how to obtain \(F_X(x)\) from \(f_X(x)\). In order to go in the reverse direction, we recall the fundamental theorem of calculus. This states that if a function \(f\) is continuous, then
for some constant \(a\). Using this result for CDF and PDF, we have the following:
The probability density function (PDF) is the derivative of the cumulative distribution function (CDF):
provided \(F_X\) is differentiable at \(x\). If \(F_X\) is not differentiable at \(x = x_0\), then,
Consider a CDF $$F_X(x) = \begin{cases} 0, & \quad x < 0,\\ 1-\frac{1}{4}e^{-2x}, &\quad x \ge 0. \end{cases}$$ We want to find the PDF \(f_X(x)\). To do so, we first show that \(F_X(0) = \frac{3}{4}\). This corresponds to a discontinuity at \(x = 0\), as shown in Figure 4.12.

Because of the discontinuity, we need to consider three cases:
When \(x < 0\), \(F_X(x) = 0\), so \(\frac{dF_X(x)}{\;dx} = 0\).
When \(x > 0\), \(F_X(x) = 1-\frac{1}{4}e^{-2x}\), so $$\frac{dF_X(x)}{dx} = \frac{1}{2}e^{-2x}.$$
When \(x = 0\), the probability \(\Pb[X = 0]\) is determined by the gap between the solid dot and the empty dot. This yields
Therefore, the overall PDF is
Figure 4.12 illustrates this example.
4.3.4CDF: Unifying discrete and continuous random variables
The CDF is always a well-defined function. It is integrable everywhere. If the underlying random variable is continuous, the CDF is also continuous. If the underlying random variable is discrete, the CDF is a staircase function. We have seen enough CDFs for continuous random variables. Let us (re)visit a few discrete random variables.
(Geometric random variable) Consider a geometric random variable with PMF \(p_X(k) = (1-p)^{k-1}p\), for \(k = 1,2,\ldots\).

We can show that the CDF is
For a sanity check, we can try to retrieve the PMF from the CDF:
A graphical portrayal of this example is shown in Figure 4.13.
If we treat the PMFs as delta functions in the above example, then the continuous definition also applies. Since the CDF is a piecewise constant function, the derivative is exactly a delta function. For some problems, it is easier to start with CDF and then compute the PMF or PDF. Here is an example.
Let \(X_1\), \(X_2\) and \(X_3\) be three independent discrete uniform random variables with sample space \(\Omega = \{1,2,\ldots,10\}\). Define \(X = \max\{X_1,X_2,X_3\}\). We want to find the PMF of \(X\). To tackle this problem, we first observe that the PMF for \(X_1\) is \(p_{X_1}(k) = \frac{1}{10}\). Thus, the CDF of \(X_1\) is $$F_{X_1}(k) = \sum_{\ell=1}^{k}p_{X_1}(\ell) = \frac{k}{10}.$$ Then, we can show that the CDF of \(X\) is
where in \((a)\) we use the fact that \(\max\{X_1,X_2,X_3\} \le k\) if and only if all three elements are less than \(k\), and in \((b)\) we use independence. Consequently, the PMF of \(X\) is
- sep0ex
- CDF is \(F_X(x) = \Pb[X \le x]\). It is the cumulative sum of the PMF/PDF.
- CDF is either a staircase function, a smooth function, or a hybrid. Unlike a PDF, which is not defined for discrete random variables, the CDF is always well defined.
- CDF \(\overset{\frac{d}{dx}}{\longrightarrow}\) PDF.
- CDF \(\overset{\int}{\longleftarrow}\) PDF.
- Gap of jump in CDF = height of delta in PDF.