A probability model describes the possible outcomes of a random experiment and assigns probabilities to events. In many applications, however, we are not interested in the elementary outcomes themselves. Instead, we want to associate a numerical quantity with each outcome.
For example, when tossing a die, we may simply be interested in the number obtained. When measuring the rotational speed of a machine, the outcome of the experiment may be described by a real number. When recording the lifetime of a component, the relevant quantity is again numerical.
This motivates the concept of a random variable.
Random variables¶
Given a sample space , a random variable is a numerical function
that assigns a real number to each elementary outcome . Thus, the value taken by depends on the outcome of the random experiment.
For any two real numbers and with , consider the event
This is the event consisting of all elementary outcomes for which the corresponding value lies in the interval . Its probability,
therefore represents the probability that the random variable takes a value in the interval .
Knowledge of these probabilities for all intervals completely determines the probability distribution of the random variable . In other words, the probability distribution specifies how the probability is distributed among the possible values of .
The way in which this distribution is described depends on the type of random variable. We first consider discrete random variables and then random variables having a probability density.
Discrete random variables¶
A random variable is called discrete if it takes values in a finite or countably infinite set. Denote the possible values of by .
The probability assigned to each possible value is described by the probability mass function (PMF):
Since must take one of its possible values, these probabilities satisfy
where the sum is taken over all distinct values that can assume.
For a discrete random variable, the probability that takes a value in an interval is obtained by summing the probabilities of all possible values contained in that interval. Thus,
The PMF therefore completely determines the probability distribution of a discrete random variable.
Example: a fair die¶
Consider the experiment of throwing a fair six-sided die. Let denote the number appearing on the upper face. Then
and, because the six outcomes are equally likely,
For example,
Thus, probabilities for intervals are obtained by summing the corresponding point probabilities.
Continuous random variables and probability densities¶
A random variable may instead take values throughout an interval or, more generally, throughout a continuous subset of . In this case, it is useful to describe the distribution through a density.
More precisely, we say that a random variable has a probability density function (PDF), or that its distribution is absolutely continuous, if there exists a non-negative integrable function such that, for every ,
Since the total probability must be one,
Unlike a discrete random variable, a random variable having a density assigns zero probability to any individual value. Indeed, for every ,
The density should therefore not be interpreted as the probability that takes the value . Rather, it describes how probability is distributed locally around .
If is continuous at , then, for a small positive ,
Thus, for a sufficiently small interval, the probability is approximately the density at multiplied by the length of the interval.
The distribution function¶
The distribution function, also called the cumulative distribution function (CDF), of a random variable is defined by
The CDF gives the probability that the random variable does not exceed a prescribed value .
The distribution function is defined for every random variable, whether discrete, continuous, or of a more general type.
For every random variable, the CDF is non-decreasing and satisfies
It is also right-continuous:
Recovering probabilities from the CDF¶
The cumulative distribution function contains all the information needed to determine probabilities involving a random variable. By definition,
Consequently, probabilities of events defined by intervals can be obtained directly from differences of CDF values. For example,
and, for ,
The choice of strict or non-strict inequalities at the endpoints is important for a general random variable. In particular,
Thus, a jump of the CDF at represents a positive probability concentrated at the single value . Such a point is called an atom of the distribution.
For example, consider a random variable such that
Its CDF is a step function, and the jump at has size 0.5. Hence,
More generally, for ,
while
For continuous random variables with a density, individual points have probability zero. Therefore, the distinction between strict and non-strict inequalities at the endpoints disappears. In that case,
This illustrates an important general principle: the CDF can be used to compute probabilities for every random variable, whereas a probability mass function is specific to discrete random variables and a probability density is available only for distributions that are absolutely continuous.
The discrete case¶
If is discrete with PMF , then its CDF is obtained by summing the probabilities of all possible values that do not exceed :
The CDF is therefore a non-decreasing step function. It remains constant between two consecutive possible values of and jumps at each value that has positive probability.
The continuous case¶
If has a probability density , then its CDF is obtained by integrating the density:
In particular, the CDF is continuous. If the density is sufficiently regular, then
Thus, the PMF, PDF, and CDF provide different ways of describing a probability distribution:
the PMF assigns probabilities to individual values in the discrete case;
the PDF describes the local distribution of probability for an absolutely continuous random variable;
the CDF gives the probability that the random variable does not exceed a prescribed value and applies to both discrete and continuous distributions.
The discrete CDF is a step function because the random variable can only take isolated values. The continuous CDF is continuous because the distribution has a density.
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import binom, norm
fig, (ax1, ax2) = plt.subplots(
1, 2, figsize=(12, 5), layout="constrained"
)
# Discrete CDF: Binomial distribution
n, p = 10, 0.5
x_discrete = np.arange(0, n + 1)
cdf_discrete = binom.cdf(x_discrete, n, p)
ax1.step(
x_discrete,
cdf_discrete,
where="post",
linewidth=2,
label="Binomial(10, 0.5) CDF",
)
ax1.plot(x_discrete, cdf_discrete, "o", alpha=0.7)
ax1.set_title("Discrete CDF")
ax1.set_xlabel(r"$x$")
ax1.set_ylabel(r"$\Phi_\xi(x)=P(\xi\leq x)$")
ax1.set_ylim(-0.05, 1.05)
ax1.grid(True, linestyle="--", alpha=0.6)
ax1.legend(loc="lower right")
# Continuous CDF: standard normal distribution
x_continuous = np.linspace(-4, 4, 1000)
cdf_continuous = norm.cdf(x_continuous)
ax2.plot(
x_continuous,
cdf_continuous,
linewidth=2,
label=r"Standard Normal $\mathcal{N}(0,1)$ CDF",
)
ax2.set_title("Continuous CDF")
ax2.set_xlabel(r"$x$")
ax2.set_ylabel(r"$\Phi_\xi(x)=P(\xi\leq x)$")
ax2.set_ylim(-0.05, 1.05)
ax2.grid(True, linestyle="--", alpha=0.6)
ax2.legend(loc="lower right")
plt.show()
The figure illustrates the fundamental difference between the two cases. In the discrete case, the CDF changes through jumps, while in the continuous case it changes continuously.
Uniform distributions¶
A particularly simple probability distribution is the uniform distribution. It models a situation in which all values in a specified interval are equally likely in the sense that equal-length intervals have equal probability.
A continuous random variable is said to be uniformly distributed on , with , and we write
if its density is constant on and zero elsewhere. Since the total area under the density must be one,
For ,
Thus, for a uniform distribution, the probability of an interval is proportional to its length.
The corresponding CDF is
The CDF is therefore constant before the interval , increases linearly inside the interval, and is equal to one after the interval.
A discrete analogue is obtained by assigning equal probability to a finite set of values. If takes the distinct values
with equal probability, then
This is called a discrete uniform distribution.
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import randint, uniform
fig, axs = plt.subplots(
2, 2, figsize=(12, 8), layout="constrained"
)
# Continuous Uniform U(a,b)
a, b = 2, 8
x_cont = np.linspace(0, 10, 1000)
pdf_cont = uniform.pdf(x_cont, loc=a, scale=b - a)
cdf_cont = uniform.cdf(x_cont, loc=a, scale=b - a)
axs[0, 0].plot(
x_cont,
pdf_cont,
linewidth=2,
label=rf"PDF: $\mathcal{{U}}({a},{b})$",
)
axs[0, 0].fill_between(
x_cont,
pdf_cont,
where=(x_cont >= a) & (x_cont <= b),
alpha=0.2,
)
axs[0, 0].set_title("Continuous Uniform PDF")
axs[0, 0].set_xlabel(r"$x$")
axs[0, 0].set_ylabel(r"$p_X(x)$")
axs[0, 0].set_ylim(-0.02, 0.25)
axs[0, 0].grid(True, linestyle="--", alpha=0.6)
axs[0, 0].legend(loc="upper right")
axs[0, 1].plot(
x_cont,
cdf_cont,
linewidth=2,
label=rf"CDF: $\mathcal{{U}}({a},{b})$",
)
axs[0, 1].set_title("Continuous Uniform CDF")
axs[0, 1].set_xlabel(r"$x$")
axs[0, 1].set_ylabel(r"$\Phi_X(x)=\mathbb{P}(X\leq x)$")
axs[0, 1].set_ylim(-0.05, 1.05)
axs[0, 1].grid(True, linestyle="--", alpha=0.6)
axs[0, 1].legend(loc="lower right")
# Discrete Uniform distribution: fair die
low, high = 1, 6
x_disc = np.arange(1, 7)
pmf_disc = randint.pmf(x_disc, low, high + 1)
axs[1, 0].stem(
x_disc,
pmf_disc,
linefmt="crimson",
markerfmt="ro",
basefmt=" ",
)
axs[1, 0].set_title("Discrete Uniform PMF (Fair Die)")
axs[1, 0].set_xlabel(r"$x$")
axs[1, 0].set_ylabel(r"$P_X(x)$")
axs[1, 0].set_xticks(x_disc)
axs[1, 0].set_ylim(-0.02, 0.25)
axs[1, 0].grid(True, linestyle="--", alpha=0.6)
x_disc_cdf = np.arange(0, 8)
cdf_disc = randint.cdf(x_disc_cdf, low, high + 1)
axs[1, 1].step(
x_disc_cdf,
cdf_disc,
where="post",
color="crimson",
linewidth=2,
label="Discrete CDF",
)
axs[1, 1].plot(x_disc_cdf, cdf_disc, "ro", alpha=0.7)
axs[1, 1].set_title("Discrete Uniform CDF")
axs[1, 1].set_xlabel(r"$x$")
axs[1, 1].set_ylabel(r"$\Phi_X(x)=\mathbb{P}(X\leq x)$")
axs[1, 1].set_ylim(-0.05, 1.05)
axs[1, 1].grid(True, linestyle="--", alpha=0.6)
axs[1, 1].legend(loc="lower right")
plt.show()
Example: uncertain rotational speed of a mechanical system¶
Random variables are particularly useful for representing uncertain physical quantities.
Suppose that the rotational speed of a shaft varies during operation. Let
Assume that, during a particular operating regime, the rotational speed can take any value between 1800 rpm and 2200 rpm with equal likelihood. We model this by
Its density is therefore
For example, the probability that the rotational speed lies between 1900 rpm and 2000 rpm is
Thus, under the assumed model, there is a probability that the rotational speed lies between 1900 rpm and 2000 rpm.
The same calculation can be performed directly using the CDF:
This illustrates the equivalence between the density and CDF descriptions of an absolutely continuous random variable.
Distributions beyond the discrete and continuous cases¶
The discrete and absolutely continuous cases are the two principal settings considered in this course, but they do not exhaust all possible probability distributions.
For example, a random variable may have both discrete and continuous components. Such a distribution is called a mixed distribution.
There are also continuous distribution functions that cannot be represented by an ordinary probability density function. Thus, the statement that a random variable is continuous should not, in complete generality, be taken to mean that it necessarily has a density.
For the purposes of the present course, however, the distinction between discrete random variables described by PMFs and absolutely continuous random variables described by PDFs will cover the main examples and applications.
Summary¶
A random variable assigns a real number to each outcome of a random experiment.
For a discrete random variable, the probability distribution is described by the probability mass function
with
For an absolutely continuous random variable, the probability distribution is described by a density satisfying
Probabilities are obtained by summation in the discrete case and integration in the continuous case.
The cumulative distribution function
provides a unified description of the distribution. In particular,
For a discrete random variable, the CDF is a step function. For a random variable with a density, the CDF is continuous and is obtained by integrating the density.
The next step is to study important families of probability distributions, including the Bernoulli, binomial, Poisson, and normal distributions. These distributions provide models for many common random phenomena and will also provide the foundation for the study of expectation, variance, and limit theorems in the subsequent lectures.