St · Statistics & Probability

How to Find a PMF and CDF

Published By the 9to5Science editorial team

At a glance

  1. 1. Identify the variable type

    A PMF applies to discrete variables; a CDF applies to both discrete and continuous variables.

  2. 2. List possible values

    Write every value the random variable can take and determine its probability or density.

  3. 3. Check the probabilities

    For a PMF, verify that every probability is nonnegative and that the total is one.

  4. 4. Accumulate probabilities

    Construct the CDF by adding probabilities up to each value, or integrating the density up to x.

A probability mass function (PMF) describes the probabilities of a discrete random variable. A cumulative distribution function (CDF) describes the probability that a random variable is less than or equal to a given number. The PMF is used only for discrete variables, while every random variable has a CDF.

The usual workflow is: identify the possible values of the random variable, find the probability of each value, and then accumulate those probabilities to obtain the CDF.

PMF definition

If XX is a discrete random variable, its PMF is

pX(x)=P(X=x).p_X(x)=P(X=x).

A valid PMF must satisfy two conditions:

pX(x)≥0p_X(x)\ge 0

for every xx, and

∑xpX(x)=1.\sum_x p_X(x)=1.

The sum is taken over all possible values of XX. Values that XX cannot take have probability zero and may be omitted from the table.

CDF definition

The CDF of any random variable XX is

FX(x)=P(X≤x).F_X(x)=P(X\le x).

For a discrete random variable, obtain it from the PMF by summing all probabilities at or below xx:

FX(x)=∑t≤xpX(t).F_X(x)=\sum_{t\le x}p_X(t).

The phrase “at or below” matters: the CDF uses X≤xX\le x, not X<xX<x.

A CDF always has values between zero and one, is nondecreasing, approaches zero toward the left, and approaches one toward the right.

Worked example: two coin tosses

Suppose a fair coin is tossed twice, and let XX be the number of heads. The possible values are 00, 11, and 22.

The four equally likely outcomes are

TT,HT,TH,HH.TT,\quad HT,\quad TH,\quad HH.

Here TT means tails and HH means heads. Count the outcomes corresponding to each value of XX:

xxOutcomesPMF pX(x)=P(X=x)p_X(x)=P(X=x)
0TTTT1/41/4
1HT,THHT,TH2/4=1/22/4=1/2
2HHHH1/41/4

Therefore,

pX(x)={14,x=0,12,x=1,14,x=2,0,otherwise.p_X(x)= \begin{cases} \frac14, & x=0,\\ \frac12, & x=1,\\ \frac14, & x=2,\\ 0, & \text{otherwise}. \end{cases}

The probabilities add to one:

14+12+14=1.\frac14+\frac12+\frac14=1.

Now construct the CDF by accumulating the PMF values.

  • If x<0x<0, no possible value is at most xx, so FX(x)=0F_X(x)=0.
  • If 0≤x<10\le x<1, only the value 00 is included, so FX(x)=1/4F_X(x)=1/4.
  • If 1≤x<21\le x<2, the values 00 and 11 are included, so FX(x)=1/4+1/2=3/4F_X(x)=1/4+1/2=3/4.
  • If x≥2x\ge2, all possible values are included, so FX(x)=1F_X(x)=1.

Thus,

FX(x)={0,x<0,14,0≤x<1,34,1≤x<2,1,x≥2.F_X(x)= \begin{cases} 0, & x<0,\\ \frac14, & 0\le x<1,\\ \frac34, & 1\le x<2,\\ 1, & x\ge2. \end{cases}

The CDF is a step function. It jumps by 1/41/4 at x=0x=0, by 1/21/2 at x=1x=1, and by 1/41/4 at x=2x=2. In general, the jump at a point xx equals the PMF value pX(x)p_X(x).

Finding probabilities from the CDF

Once the CDF is known, you can calculate interval probabilities. For example,

P(a<X≤b)=FX(b)−FX(a).P(a<X\le b)=F_X(b)-F_X(a).

For the coin-toss example,

P(0<X≤2)=FX(2)−FX(0)=1−14=34.P(0<X\le2)=F_X(2)-F_X(0)=1-\frac14=\frac34.

This correctly counts the cases X=1X=1 and X=2X=2 while excluding X=0X=0.

For a discrete variable, a single-point probability can also be recovered from the CDF using the left-hand limit:

pX(x)=FX(x)−FX(x−),p_X(x)=F_X(x)-F_X(x^-),

where FX(x−)F_X(x^-) denotes the value approached from the left. In the example, the jump at x=1x=1 is

pX(1)=FX(1)−FX(1−)=34−14=12.p_X(1)=F_X(1)-F_X(1^-)=\frac34-\frac14=\frac12.

If the variable is absolutely continuous

If XX is absolutely continuous—that is, its distribution has a probability density function (PDF)—then it does not have a PMF in the usual sense. Individual points have probability zero:

P(X=x)=0.P(X=x)=0.

Its CDF is found by integrating its PDF fX(x)f_X(x):

FX(x)=P(X≤x)=∫−∞xfX(t) dt.F_X(x)=P(X\le x)=\int_{-\infty}^{x}f_X(t)\,dt.

Not every continuous random variable has a PDF, but the following formula applies whenever a PDF exists.

For example, if XX is uniform on [0,2][0,2], its density is

fX(x)={12,0≤x≤2,0,otherwise.f_X(x)= \begin{cases} \frac12, & 0\le x\le2,\\ 0, & \text{otherwise}. \end{cases}

Integrating gives

FX(x)={0,x<0,x2,0≤x≤2,1,x>2.F_X(x)= \begin{cases} 0, & x<0,\\ \frac{x}{2}, & 0\le x\le2,\\ 1, & x>2. \end{cases}

For instance,

P(0.5≤X≤1.5)=FX(1.5)−FX(0.5)=1.52−0.52=12.P(0.5\le X\le1.5)=F_X(1.5)-F_X(0.5) =\frac{1.5}{2}-\frac{0.5}{2}=\frac12.

A mixed random variable can have both point masses and a continuous component. In that case, the CDF still works, but there is no single PMF that describes the entire distribution.

Common mistakes

Confusing PMF and CDF

The PMF gives the probability of one exact value, P(X=x)P(X=x). The CDF gives the probability of all values up to a point, P(X≤x)P(X\le x).

Forgetting cumulative addition

For a discrete variable, the CDF is not usually equal to the PMF. At x=2x=2, for example, it includes the probabilities of X=0X=0, X=1X=1, and X=2X=2.

Using a PMF for a continuous variable

For an absolutely continuous variable, use a PDF and integrate it. More generally, a continuous distribution need not have a PDF. The probability at a single point is zero, even though the density at that point may be positive.

Ignoring intervals between possible values

If a discrete variable takes integer values, FX(x)F_X(x) is constant between consecutive integers. For example, if 1≤x<21\le x<2, the CDF includes the probability of X=1X=1 but not X=2X=2.

Failing to check the total

A proposed discrete distribution is invalid if its PMF values do not sum to one. This check often catches missing outcomes or incorrect counting.

References

  1. Introduction to Probability Models, Sheldon M. Ross
  2. A First Course in Probability, Sheldon Ross

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.