In this chapter, we restrict ourselves to study a special type of random variables - the discrete random variables.
When an experiment is performed, we are often interested in some functions of the outcomes, rather than the outcomes themselves. For example, when we toss two six-sided dice, we may care about the sum of the two dice. These real-valued functions defined on the sample space are known as random variables.
A random variable is said to be discrete if it can take a finite or countable infinite number of distinct values. In practice, we usually use an uppercase letter to denote a random variable. For example, $X: S \rightarrow \mathbb{R}$, and a lowercase letter, say $x$, to denote a possible value of this random variable. When we say $X=x$, we’re referring to the set of outcomes on the sample space such that $\{X=x\}$ holds. As an example,
$$ \begin{gathered} X: \text{sum of two dice rolls} \\ \{X = 7\} = \{ (1, 6), (2, 5), \cdots, (6, 1) \} \end{gathered} $$
Then we can assign a probability to each of the events. The probability mass function (PMF) of a discrete random variable $X$ at a given value $x$ is denoted
$$ P\{X = x\} = p_X(x) $$
The probability distribution of a discrete random variable X is a collection of its probability mass functions over all its possible values. In other words, a collection of $p(x)$ for all $X$.
<aside> ❓ Consider an experiment of tossing two fair coins. Denote $X$ as the number of heads. Find the probability distribution of $X$.
</aside>
Our sample space is
$$ S = \{ (H, H), (H, T), (T, H), (T, T) \} $$
For the random variable $X$: the number of heads, if we view $X$ as a function of $S$,
$$ \begin{cases} X((H, H)) = 2 \\ X((H, T)) = 1 \\ X((T, H)) = 1 \\ X((T, T)) = 0 \end{cases} $$
$X$ can take three possible values: 0, 1 and 2. The probability mass functions are
$$ \begin{aligned} p_X(0) &= P\{ X = 0 \} = P\{(T, T)\} = \frac{1}{4} \\ p_X(1) &= P\{ X = 1 \} = P\{(T, H), (H, T)\} = \frac{1}{2} \\ p_X(2) &= P\{ X = 2 \} = P\{(H, H)\} = \frac{1}{4} \end{aligned} $$
So the probability distribution of $X$ is given by
$$ P(X) = \begin{cases} 0.25, & X = 0, 2 \\ 0.5, & X = 1 \end{cases} $$
Often a bar plot is used to show the probability distribution of $X$, with possible values of $X$ on the x-axis, and $P(X)$ on the y-axis.
library(ggpubr)
dat <- data.frame(
X = c(0, 1, 2),
P = c(0.25, 0.5, 0.25)
)
ggbarplot(dat, "X", "P", ylab = "P(X)", width = 0.5)

Bar plot of the probability distribution of $X$.