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.
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.
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
Xtakes the values0, 1, 2, 3with massesp = 0.1, 0.3, 0.4, 0.2. Find the CDF, thenP(X ≤ 2)andP(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 iffp(x) ≥ 0andΣ 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 byp(x)at each value. - Interval chance:
P(a < X ≤ b) = F(b) − F(a); a single jump is the massP(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
Practice this in an interview
All questionsEach 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.
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).
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.
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.