datarekha

Random Variables, PMF & CDF

Toss three coins and count the heads — you have just turned a messy outcome into a single number. Name that and it is a random variable; list its chances and that is the PMF; add them up as you go and that is the CDF. The shared language of every distribution that follows.

8 min read Intermediate GATE DA Lesson 8 of 122

What you'll learn

  • A random variable turns each outcome into a number; discrete vs continuous
  • PMF p(x): non-negative masses that sum to 1
  • CDF F(x) = P(X ≤ x): non-decreasing, right-continuous, a step function for a discrete RV
  • Reading interval chances off the CDF: P(a < X ≤ b) = F(b) − F(a)

Before you start

Toss three coins and count how many come up heads. The answer is a number — 0, 1, 2, or 3 — and that small act, of turning a messy outcome like heads-tails-heads into a single tidy number, is something you do without thinking. Give the act a name and it becomes the workhorse of everything that follows in probability.

Naming the act

A rule that turns each outcome of an experiment into a number is a random variable. Counting heads is one; so is the score on a die, or the time you wait for a bus. When the numbers sit on a separated, countable list — 0, 1, 2, 3 heads — the variable is discrete, and that is this lesson. When they can land anywhere in a stretch — any waiting time at all — it is continuous, which waits for the next lesson.

Two companions describe a discrete random variable completely: a list of its chances, and a running total of them.

The list and the running total

The list is the probability mass function, p(x) = P(X = x) — the chance of each individual value. For it to make sense, two things must hold, and both are just the axioms from before: no chance is negative, and the chances over all the values add up to one whole.

p(x) ≥ 0   for every x        and        Σ p(x) = 1

The running total is the cumulative distribution function, F(x) = P(X ≤ x) — the chance of landing at x or anywhere below it. Because it only ever adds non-negative masses as x moves right, the running total can climb or stay level but never fall. And for a discrete variable it climbs in jumps: it leaps upward by p(x) exactly at each value, then runs flat until the next one. Drawn out, it is a staircase.

PMF p(x)CDF F(x) = P(X ≤ x)0123.1.3.4.20123.1.4.81Each bar’s height is added in: the CDF jumps by p(x) at each value and is flat between.
The PMF lists the masses; the CDF is their running total — a staircase for a discrete RV.

That staircase shape carries the properties GATE tests, and a 2025 MSQ asked exactly which of them hold for every CDF. They follow from “running total of non-negative masses”: F is non-decreasing, it is right-continuous (at a jump it already sits at the higher value), and it runs from F(−∞) = 0 up to F(+∞) = 1.

Reading chances off the staircase

Once you have the staircase, one identity does most of the work. The chance of landing in an interval is the height climbed across it — the total at the top minus the total already counted at the bottom:

P(a < X ≤ b) = F(b) − F(a)

And a single jump is a single mass: P(X = x) = F(x) − F(x⁻), the height of the step at x.

Watching it built, value by value

A discrete random variable X takes the values 0, 1, 2, 3 with masses p = 0.1, 0.3, 0.4, 0.2. Find the CDF, then P(X ≤ 2) and P(1 < X ≤ 3).

First check it is a real PMF: every mass is non-negative, and 0.1 + 0.3 + 0.4 + 0.2 = 1. Good. Now accumulate left to right, each entry the running total so far:

x         0      1      2      3
p(x)     0.1    0.3    0.4    0.2
F(x)     0.1    0.4    0.8    1.0      ← running total

P(X ≤ 2)     = F(2)              = 0.8
P(1 < X ≤ 3) = F(3) − F(1)       = 1.0 − 0.4 = 0.6

P(X ≤ 2) is simply the staircase’s height at 2, the running total 0.1 + 0.3 + 0.4. The interval P(1 < X ≤ 3) leaves out X = 1 but keeps X = 3, so it is the masses at 2 and 3, 0.4 + 0.2 = 0.6 — which is exactly F(3) − F(1).

A question to carry forward

A full PMF table — every value and its mass — is more than you usually want to carry around. Here is the thread for the next lesson: most of the time two numbers would do, one saying roughly where the variable sits and one saying roughly how much it swings. How do we boil a whole table down to those two summary numbers?

In one breath

  • A random variable turns each outcome into a number; discrete = a countable list of values (this lesson), continuous = a range (next).
  • PMF p(x) = P(X=x): valid iff p(x) ≥ 0 and Σ p(x) = 1.
  • CDF F(x) = P(X ≤ x) = running total: non-decreasing, right-continuous, F(−∞)=0, F(+∞)=1; a staircase for a discrete RV, jumping by p(x) at each value.
  • Interval chance: P(a < X ≤ b) = F(b) − F(a); a single jump is the mass P(X=x) = F(x) − F(x⁻).
  • The 2025 MSQ trap: a CDF is right-continuous and non-decreasing — never left-continuous, never decreasing.

Practice

Quick check

0/6
Q1Recall: what two conditions make p(x) a valid PMF?
Q2Trace: a discrete RV X has p(0)=0.2, p(1)=0.5, p(2)=0.3. Compute P(X ≤ 1).numerical answer — type a number
Q3Trace: a discrete CDF has F(1)=0.4 and F(2)=0.9, with no X-values strictly between 1 and 2. Find P(X = 2).numerical answer — type a number
Q4Apply: with p(0)=0.2, p(1)=0.5, p(2)=0.3, compute P(0 < X ≤ 2).numerical answer — type a number
Q5Apply: which statements are TRUE for the CDF F(x) of any random variable? (select all that apply)select all that apply
Q6Create: from a CDF with F(0)=0.1, F(1)=0.4, F(2)=0.8, F(3)=1.0, find P(X ≥ 2) and explain the boundary choice.

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Practice this in an interview

All questions
When does each common distribution arise — Bernoulli, Binomial, Poisson, Normal, Exponential, Uniform?

Each distribution has a natural generative story: Bernoulli is a single coin flip; Binomial sums Bernoullis; Poisson counts rare arrivals; Normal emerges from sums of many small effects; Exponential models waiting times between Poisson events; Uniform assigns equal probability across a range. Choosing correctly comes from matching that story to the data-generating process.

Explain joint, marginal, and conditional distributions and how to move between them.

The joint distribution P(X, Y) fully specifies two random variables together. Marginals P(X) and P(Y) are obtained by summing (or integrating) the joint over the other variable. Conditionals P(X|Y=y) are the joint sliced at a fixed y value, renormalized by the marginal P(Y=y).

How does the Bernoulli distribution relate to the Binomial, and what are their parameters and moments?

A Bernoulli(p) trial is the atomic unit: a single experiment with success probability p. Binomial(n, p) is the sum of n independent, identically distributed Bernoulli(p) trials, counting total successes. Because Binomial is a sum of independent random variables, its mean and variance are n times those of a single Bernoulli.

State the law of total probability and give a concrete example of when you'd apply it.

The law of total probability decomposes P(A) over a mutually exclusive, exhaustive partition of the sample space: P(A) = Σ P(A|Bᵢ)·P(Bᵢ). It is the engine behind the Bayes denominator and any calculation where you want an overall rate built from segment-level rates.

Related lessons

Explore further

Skip to content