Tutorials › Statistical Theory I - Probability and Distribution Theory › Building a CDF on a Finite Outcome Space

Random Variables and Distribution Functions · Tutorial 28 of 994

Building a CDF on a Finite Outcome Space

Build a finite random variable’s CDF from its possible values and probabilities, then use the ordered cumulative totals to evaluate it at specified thresholds.

Beginner 9 min read

What You'll Learn

  • Group sample outcomes that produce the same random-variable value
  • Order the distinct values and add their probabilities cumulatively
  • Write a finite-valued CDF as a piecewise function
  • Evaluate CDF values at thresholds between, equal to, and beyond possible values
  • Avoid confusing the outcomes of an experiment with the values of the random variable

From Possible Values to a CDF

When a random variable can take only finitely many values, its cumulative distribution function can be built directly from a short list. The main work is to identify the distinct numerical values the variable can take, determine the probability of each value, put those values in increasing order, and accumulate the probabilities.

The order and the word “distinct” matter. Several outcomes in the underlying experiment may produce the same value of \(X\). Their probabilities must first be combined. Then the CDF at a threshold \(x\) includes the probability of every value of \(X\) that is less than or equal to \(x\).

Definition: For a real-valued random variable \(X\), its cumulative distribution function (CDF) is \(F(x)=P(X\leq x)\), for every real number \(x\). If \(X\) has distinct possible values \(x_1<\cdots<x_k\), and \(q_j=P(X=x_j)\), then its finite CDF is
$$ F(x)=\sum_{j=1}^{k}q_j\,\mathbf{1}\{x_j\leq x\}, $$
where \(\mathbf{1}\{x_j\leq x\}\) is 1 when \(x_j\leq x\) and 0 otherwise. Equivalently, add the probabilities \(q_j\) for all listed values at or below \(x\).

Here \(q_j\) is the probability of a value of \(X\), not necessarily the probability of a single elementary outcome. To find \(q_j\), collect every outcome \(\omega\) for which \(X(\omega)=x_j\) and add the probabilities of those outcomes. In a finite probability model, this is a finite addition.

A Reliable Construction

Use the following procedure whenever the underlying outcome space is finite. If the experiment’s outcomes have probabilities \(P(\{\omega\})\), group them according to the value \(X(\omega)\). Sort the resulting distinct values as \(x_1<\cdots<x_k\), and set \(q_j=P(X=x_j)\). The accumulated totals are \(Q_j=q_1+\cdots+q_j\).

1
List and group.
Write down what value \(X\) assigns to each possible outcome. Combine outcomes that give the same value.
2
Order the values.
Arrange the distinct values from smallest to largest, and write the probability of each value beside it.
3
Accumulate.
Add the probability at each value to the total from all smaller values. The resulting total is the CDF on the interval up to the next value.
4
Evaluate the requested threshold.
Include a value exactly equal to the threshold, as well as every smaller value. Do not include larger values.

For an ordered list \(x_1<\cdots<x_k\), the piecewise form is

$$ F(x)= \begin{cases} 0, & x<x_1,\\ Q_j, & x_j\leq x<x_{j+1},\quad j=1,\ldots,k-1,\\ 1, & x\geq x_k. \end{cases} $$

This expression is simply a compact way to record which listed values are at or below \(x\). Between two consecutive possible values, changing the threshold does not add any new probability. At a listed value, its probability is included.

Theorem: Suppose a finite probability model has outcomes \(\omega_1,\ldots,\omega_m\), with \(P(\{\omega_i\})=p_i\), and \(X(\omega_i)\) is real-valued. For each distinct value \(x_j\) of \(X\),
$$ q_j=P(X=x_j)=\sum_{\{i:X(\omega_i)=x_j\}}p_i, \qquad F(x)=\sum_{\{i:X(\omega_i)\leq x\}}p_i. $$
Thus grouping equal values and accumulating their probabilities gives exactly the CDF.

Proof. The event \(\{X=x_j\}\) consists precisely of the outcomes \(\omega_i\) whose assigned value is \(x_j\). These single-outcome events are disjoint, so finite additivity gives \(P(X=x_j)=\sum_{\{i:X(\omega_i)=x_j\}}p_i\). Likewise, \(\{X\leq x\}\) consists precisely of the outcomes whose assigned values are at most \(x\). The single-outcome events in this set are disjoint, so its probability is the sum of their probabilities: \(F(x)=P(X\leq x)=\sum_{\{i:X(\omega_i)\leq x\}}p_i\). Grouping the terms in this sum by their common value \(x_j\) gives the accumulated-probability formula. \(\square\)

Worked Example: A Function of One Fair Die

A fair six-sided die has outcomes \(1,2,3,4,5,6\), each with probability \(1/6\). Define \(X\) to be 0 on die outcomes 1 or 2, 1 on outcomes 3, 4, or 5, and 3 on outcome 6. Construct \(F\), then find \(F(1)\) and \(F(2)\).

First group the outcomes by the value assigned to \(X\). The distinct values are \(0,1,3\), and their probabilities are \(P(X=0)=2/6=1/3\), \(P(X=1)=3/6=1/2\), and \(P(X=3)=1/6\). The probabilities sum to \(1/3+1/2+1/6=2/6+3/6+1/6=1\), as required.

In increasing order, the cumulative totals are \(1/3\) at value 0, \(1/3+1/2=5/6\) at value 1, and \(5/6+1/6=1\) at value 3. Therefore

$$ F(x)= \begin{cases} 0, & x<0,\\ 1/3, & 0\leq x<1,\\ 5/6, & 1\leq x<3,\\ 1, & x\geq 3. \end{cases} $$

Since \(1\leq 1<3\), \(F(1)=5/6\). The probability at \(X=1\) is included. Also \(1\leq 2<3\), so \(F(2)=5/6\). The threshold 2 is not itself a possible value, but it includes the same possible values, 0 and 1, as threshold 1.

Worked Example: Combining Outcomes With Unequal Probabilities

A finite experiment has four outcomes \(a,b,c,d\), with probabilities \(0.10, 0.20, 0.30, 0.40\), respectively. A random variable assigns \(X(a)=2\), \(X(b)=0\), \(X(c)=2\), and \(X(d)=5\). Construct its CDF and evaluate \(F(1)\), \(F(2)\), and \(F(4)\).

The distinct values are \(0,2,5\). The value 2 comes from two outcomes, so its probability is \(P(X=2)=P(\{a\})+P(\{c\})=0.10+0.30=0.40\). The full grouped list is \(P(X=0)=0.20\), \(P(X=2)=0.40\), and \(P(X=5)=0.40\). These probabilities total \(0.20+0.40+0.40=1.00\).

The cumulative totals in order are \(0.20\), \(0.20+0.40=0.60\), and \(0.60+0.40=1.00\). Thus

$$ F(x)= \begin{cases} 0, & x<0,\\ 0.20, & 0\leq x<2,\\ 0.60, & 2\leq x<5,\\ 1, & x\geq 5. \end{cases} $$

At \(x=1\), only the value 0 is at or below the threshold, so \(F(1)=0.20\). At \(x=2\), both 0 and 2 are included, so \(F(2)=0.20+0.40=0.60\). At \(x=4\), the included values are still 0 and 2, so \(F(4)=0.60\). In particular, the probability \(0.40\) attached to the value 5 is not included at threshold 4.

Why the Cumulative Total Is the Right One

The event defining the CDF at \(x\) is \(\{X\leq x\}\), not just \(\{X=x\}\). When the possible values are ordered, this event is the union of all value-events at or below \(x\). Those events are disjoint: \(X\) cannot equal two different values at once. Consequently, their probabilities add. This explains both why the accumulation works and why the order of the values determines the piecewise intervals.

Result: If \(x_j\leq x<x_{j+1}\), then \(F(x)=q_1+\cdots+q_j\). This follows because \(x_1,\ldots,x_j\) are exactly the distinct possible values that are at most \(x\). No value \(x_{j+1},\ldots,x_k\) is at most \(x\), so their probabilities do not enter the sum.

For \(x<x_1\), no possible value is at or below \(x\), so the sum is empty and \(F(x)=0\). For \(x\geq x_k\), every possible value is at or below \(x\), so the sum is \(q_1+\cdots+q_k=1\). These cases complete the finite piecewise description.

Worked Example: Number of Heads in Two Fair Coin Tosses

Toss a fair coin twice, with the four equally likely ordered outcomes \(HH, HT, TH, TT\). Let \(X\) be the number of heads. Construct the CDF and find \(F(0.5)\), \(F(1)\), and \(F(1.5)\).

The outcomes \(TT\), \(HT\) and \(TH\), and \(HH\) give \(X=0\), \(X=1\), and \(X=2\), respectively. Therefore \(P(X=0)=1/4\), \(P(X=1)=2/4=1/2\), and \(P(X=2)=1/4\). The total is \(1/4+1/2+1/4=1\).

In increasing order, the cumulative totals are \(1/4\), \(1/4+1/2=3/4\), and \(3/4+1/4=1\). Hence

$$ F(x)= \begin{cases} 0, & x<0,\\ 1/4, & 0\leq x<1,\\ 3/4, & 1\leq x<2,\\ 1, & x\geq 2. \end{cases} $$

Because \(0\leq 0.5<1\), \(F(0.5)=1/4\). At the threshold \(1\), the event is \(X\leq 1\), which includes both zero and one head, so \(F(1)=1/4+1/2=3/4\). Since \(1\leq 1.5<2\), \(F(1.5)=3/4\). These evaluations show why the threshold must be compared with the possible values, rather than treated as though it must itself be a possible value.

Common Mistake: Forgetting to Group or Include Equality

A frequent error is to put one row in the CDF table for every elementary outcome, even when several outcomes give the same value of \(X\). For example, in the two-toss example, counting the outcome \(HT\) but not \(TH\) as the value 1 would incorrectly assign probability \(1/4\), rather than \(1/2\), to \(X=1\). The correction is to collect all outcomes with that value and add their probabilities before forming cumulative totals.

Another error is to evaluate \(F(1)\) as \(P(X<1)\). That is the wrong event: by definition, \(F(1)=P(X\leq 1)\). In the two-toss example, \(P(X<1)=1/4\), while \(F(1)=P(X=0)+P(X=1)=1/4+1/2=3/4\). At a threshold equal to a listed value, include that value’s probability.

A practical check is to verify that the grouped probabilities sum to 1 and that each cumulative total adds exactly the next probability. Then, for a requested threshold, mark which listed values satisfy \(x_j\leq x\) and add only their probabilities.

Check Your Understanding

For each question, begin by identifying the distinct values and their probabilities.

  1. A variable takes values \(-1,2,4\) with probabilities \(0.2,0.5,0.3\), respectively. Write its CDF piecewise and find \(F(2)\).
  2. Three equally likely outcomes are assigned values \(0,0,3\). What is the probability of each distinct value, and what is \(F(1)\)?
  3. A random variable takes values \(1\) and \(6\) with probabilities \(0.7\) and \(0.3\). Find \(F(5)\) and \(F(6)\).
  4. Explain why probabilities of different outcomes that share the same value of \(X\) must be combined before constructing the ordered cumulative totals.
  5. For possible values \(-2,0,5\), which values contribute to \(F(0)\), and which contribute to \(F(3)\)?