Week 9: Random Variables, PMF & CDF
3377 words
17 min read
2026-09-12T00:00:00.000Z
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
Random variables mapping S to R, discrete vs continuous, Probability Mass Function (PMF), and Cumulative Distribution Function (CDF). # Statistics for Data Science I — Week 9: Random Variables, PMF & CDF IITM’s Week 9 introduces **random variables, random experiments and sample spaces, discrete and continuous random...

Statistics for Data Science I — Week 9: Random Variables, PMF & CDF
IITM’s Week 9 introduces random variables, random experiments and sample spaces, discrete and continuous random variables, probability mass functions, and cumulative distribution functions.
TL;DR
Until now, probability dealt directly with events.
Week 9 introduces a function:
called a random variable.
It assigns a numerical value to each outcome.
Example:
Two coin tosses:
Define:
Then:
From there we study the distribution of X rather than the raw sample-space outcomes.
1. Random experiment recap
A random experiment is a process with uncertain outcome.
Examples:
- toss coins
- roll dice
- count arrivals
- measure waiting time
- observe rainfall
Every experiment has a sample space:
2. Random variable
A random variable is a function assigning a real number to each outcome:
Despite the name, the function itself is not "random."
The randomness comes from which outcome in S occurs.
3. Example: one coin
Sample space:
Define:
Then X is a numerical encoding of the random experiment.
4. Example: two coins
Let:
Then:
| Outcome | X |
|---|---|
| HH | 2 |
| HT | 1 |
| TH | 1 |
| TT | 0 |
Possible values of X:
Notice:
sample-space outcomes collapse into:
possible random-variable values.
5. Why random variables are useful
Raw outcomes can be complicated.
Example:
But often we only care about a numerical feature:
- number of heads
- total sales
- waiting time
- number of failures
- temperature
- profit
So random variables compress the experiment into a quantity we can analyze.
6. Capital vs lowercase notation
Typically:
denotes the random variable.
A specific observed value is written:
For example:
means the random variable takes value 3.
7. Event generated by a random variable
Statements such as:
represent events.
Example:
If X is number of heads in two tosses:
Similarly:
8. Probability notation
We write:
to mean:
probability that random variable X takes value x.
Example:
9. Discrete random variable
A random variable is discrete if it takes values in a finite or countable set.
Examples:
- number of heads
- number of defects
- number of customers
- die result
- number of goals
Possible values might be:
10. Continuous random variable
A random variable is continuous when its possible values form a continuum.
Examples:
- height
- waiting time
- temperature
- distance
- lifetime of a component
Possible values can lie throughout an interval:
or:
11. Discrete vs continuous
Discrete
Usually associated with counting.
Example:
Continuous
Usually associated with measurement.
Example:
This mirrors the data-type distinction from Week 1.
12. Probability distribution
A probability distribution describes:
which values the random variable can take, and how probable those values are.
For a discrete variable, we often display:
| x | P(X=x) |
|---|---|
| 0 | 0.25 |
| 1 | 0.50 |
| 2 | 0.25 |
The probabilities must satisfy:
and:
13. Probability mass function
For a discrete random variable, the probability mass function or PMF is:
It assigns a probability mass to every possible value.
14. PMF conditions
A valid PMF must satisfy:
for every x, and:
These two checks are fundamental.
15. Example: fair die
Let:
Then:
PMF:
for:
Otherwise:
16. Piecewise PMF notation
We can write:
This is a common mathematical form.
17. Example: number of heads in two tosses
For fair independent tosses:
Probabilities:
So:
18. Event probabilities from PMF
Suppose we want:
Then:
Thus:
For discrete RVs, probabilities over a set of values are found by adding PMF values.
19. Example
Suppose:
| x | pX(x) |
|---|---|
| 0 | 0.1 |
| 1 | 0.2 |
| 2 | 0.4 |
| 3 | 0.3 |
Find:
Then:
20. Solving for unknown PMF constants
Suppose:
for:
Since total probability is 1:
So:
Thus:
21. Always normalize
The standard strategy for an unknown PMF constant is:
Then solve for the parameter.
22. Cumulative distribution function
The CDF of a random variable X is:
This definition works for:
- discrete RVs
- continuous RVs
- mixed distributions
So the CDF is more universal than the PMF.
23. CDF intuition
The CDF asks:
How much probability has accumulated up to x?
Hence the word:
cumulative.
24. Discrete CDF example
Suppose:
| x | P(X=x) |
|---|---|
| 0 | 0.2 |
| 1 | 0.3 |
| 2 | 0.4 |
| 3 | 0.1 |
Then:
25. CDF as accumulated PMF
For discrete X:
So:
PMF = individual masses
CDF = accumulated mass
26. Shape of a discrete CDF
A discrete CDF looks like a staircase.
Conceptually:
textF(x) 1.0 | ________ | ______| 0.5 | _____| |___| 0.0 +-----------------------> x
It jumps at values where:
27. Size of a CDF jump
For a discrete variable:
where:
means the CDF value immediately to the left of x.
So a PMF value corresponds to a jump size.
28. Basic properties of a CDF
Every valid CDF satisfies:
It is nondecreasing:
And:
29. Why CDF cannot decrease
If:
then:
Therefore:
Hence F must be nondecreasing.
30. Probability from CDF
For:
This is one of the most useful CDF rules.
31. Why?
Since:
can be split into:
and:
we get:
Rearrange.
32. Discrete endpoint care
For discrete variables:
may differ from:
because:
can be positive.
So endpoint symbols matter.
33. Continuous RV endpoint intuition
For a continuous random variable:
Therefore:
For continuous distributions, individual points have zero probability.
34. Important continuous-variable fact
A continuous random variable can take infinitely many values, but:
for every single exact value x.
This initially feels strange.
It means probability is assigned to intervals, not individual points.
35. Zero probability does not mean impossible
For a continuous random variable:
yet the observed value could theoretically equal that number.
In continuous probability:
probability zero is not identical to logical impossibility.
This distinction becomes important later.
36. PMF does not apply to continuous RVs
PMF is for discrete random variables.
For continuous variables we later use a probability density function or PDF.
The course formally introduces continuous random variables in Week 12.
For now, understand the distinction.
37. CDF works for both
Discrete:
F(x)=P(X≤x)Continuous:
F(x)=P(X≤x)Same definition.
That is why the CDF is a universal representation of a distribution.
38. Random variable transformation intuition
Suppose:
and define:
Then:
is also a random variable.
Possible values:
A function of a random variable creates another random variable.
39. Different outcomes can give same RV value
Example:
Two dice.
Let:
Then:
all produce:
So:
This is a common PMF construction pattern.
40. PMF of two-dice sum
For two fair dice:
Number of ways:
text2 → 1 3 → 2 4 → 3 5 → 4 6 → 5 7 → 6 8 → 5 9 → 4 10 → 3 11 → 2 12 → 1
Therefore:
The PMF is not uniform even though the underlying 36 ordered die outcomes are uniform.
41. Random variable vs outcome
Do not confuse:
with:
Example:
Outcome:
If X is sum of two dice:
Outcome and random-variable value are different objects.
42. Random variable vs probability
A random variable:
is not itself a probability.
For example:
could be a possible count.
Probability is:
Do not confuse the numerical outcome with its likelihood.
43. PMF vs CDF
This distinction must be clear.
PMF
p(x)=P(X=x)Answers:
What is the probability at exactly this discrete value?
CDF
F(x)=P(X≤x)Answers:
What is the probability accumulated up to this value?
44. Example converting PMF to CDF
PMF:
| x | p(x) |
|---|---|
| 1 | 0.2 |
| 2 | 0.5 |
| 3 | 0.3 |
Then:
45. Read probability from that CDF
Find:
Using:
we get:
This corresponds to:
46. Finding PMF from CDF
Suppose CDF jumps:
- from 0 to 0.2 at x=1
- from 0.2 to 0.7 at x=2
- from 0.7 to 1 at x=3
Then PMF masses are jump sizes:
47. Support of a random variable
The support is roughly the set of values where the random variable can occur with nonzero probability/density.
For the two-head-count example:
For continuous variables, support may be an interval.
48. Indicator random variable
A useful special random variable:
This converts an event into a numerical random variable.
Then:
This becomes very useful later in statistics and probability.
49. Bernoulli-style intuition
If a random variable only takes:
or:
with:
and:
it represents a success/failure experiment.
This is the building block for Week 11's binomial distribution.
50. Discrete uniform RV
If a discrete random variable can take n values and each is equally likely:
Example:
fair die.
This is a discrete uniform distribution.
51. Not every discrete RV is uniform
For two coin tosses and number of heads:
So discrete does not imply equal probabilities.
52. Random experiment → RV workflow
textRandom experiment ↓ Sample space S ↓ Define X(ω) ↓ Find possible X values ↓ Group outcomes producing same X ↓ Compute probabilities ↓ PMF / CDF
This workflow solves many Week 9 problems.
53. Full example
Experiment:
Toss three fair coins.
Define:
Possible values:
Total outcomes:
54. Construct PMF
Exactly 0 heads:
so:
Exactly 1 head:
so:
Exactly 2 heads:
so:
Exactly 3 heads:
so:
55. Check normalization
81+83+83+81=88=1.So the PMF is valid.
56. CDF for same example
F(x)=⎩⎨⎧0,81,21,87,1,x<00≤x<11≤x<22≤x<3x≥357. Example CDF query
Find:
Directly:
Or:
58. Another query
Find:
Using CDF:
Thus:
Equivalent values:
Common mistake: probabilities need not sum to 1 over a subset
For the entire support:
But if you sum only selected values, you get the probability of that event, which may be less than 1.
Common mistake: negative PMF
A proposed PMF cannot have:
Even if all values sum to 1, one negative probability makes it invalid.
Both conditions matter.
Common mistake: CDF decreasing
A CDF can stay flat or increase.
It can never decrease.
So:
text0.2 → 0.5 → 0.4
cannot be a valid CDF.
Common mistake: CDF outside
[0,1]
A valid CDF cannot be:
or:
Always:
Common mistake: CDF ending below 1
As:
the event:
eventually includes all possible values.
Therefore:
Common mistake: confuse
P(X<x) with P(X≤x)
For discrete variables, they can differ.
For example:
excludes:
But:
includes it.
Their difference is:
Common mistake: use PMF for continuous data
For continuous random variables:
So a PMF-style table is not the right representation.
Continuous distributions are handled through density and CDF ideas.
Common mistake: sample space = support
Not necessarily.
Example:
Two coin tosses:
Sample space:
For:
support:
They are different sets.
Common mistake: every random variable uses integers
No.
Discrete RVs may take values like:
as long as the set of possible values is countable.
Continuous/discrete classification is not about whether values contain decimals.
68. Probability table completion
Suppose:
| x | p(x) |
|---|---|
| 0 | 0.2 |
| 1 | k |
| 2 | 0.5 |
Then:
Hence:
This is a standard Week 9 pattern.
69. Parameterized PMF example
Suppose:
Then:
Thus:
and:
70. Probability using parameterized PMF
Then:
So:
71. CDF can answer many event questions
Examples:
For discrete endpoint variations, carefully account for probability masses at endpoints.
72. Probability greater than a value
P(X>x)is the complement of:
Therefore:
73. Continuous case preview
For a continuous RV:
Because point probabilities are zero, endpoint choices do not matter.
This becomes more important in Week 12.
74. Why Week 9 matters
Random variables let probability theory talk about actual numerical quantities.
Without random variables:
Did the customer buy?
With random variables:
How much did the customer spend?
Without RVs:
Did an arrival happen?
With RVs:
How many arrivals occurred?
This is the bridge from event probability to statistical distributions.
75. Week 9 formula sheet
Random variable
X:S→RPMF
pX(x)=P(X=x)PMF normalization
x∑pX(x)=1CDF
FX(x)=P(X≤x)Interval from CDF
P(a<X≤b)=F(b)−F(a)Upper tail
P(X>x)=1−F(x)76. Week 9 conceptual map
textExperiment ↓ Sample space ↓ Random variable X ↓ Possible numerical values ↓ Distribution ├── Discrete │ ├── PMF │ └── CDF │ └── Continuous └── CDF ↓ PDF later
77. Weeks 7–9 progression
textWeek 7 Events and probability ↓ Week 8 Conditional probability ↓ Week 9 Random variables and distributions
The abstraction level is increasing:
78. What you should actually master
By the end of Stats 1 Week 9, you should be able to:
- Define a random variable.
- Distinguish sample-space outcomes from random-variable values.
- Construct a random variable from an experiment.
- Distinguish discrete and continuous random variables.
- Define a PMF.
- Check whether a proposed PMF is valid.
- Use: x∑p(x)=1.
- Solve for unknown PMF constants.
- Compute event probabilities from a PMF.
- Define a CDF:
- Construct a CDF from a discrete PMF.
- Recover PMF values from CDF jumps.
- Use:
- Know that CDFs are nondecreasing and lie in [0,1].
- Understand that a continuous RV has:
If those are comfortable, Stats 1 Week 9 is under control.
Quick Recall & Flashcards
Test your active recall before proceeding to practice problems. Format:
Question :: Answer.- Week 9 Diagnostic: For a discrete random variable X with PMF P(X=1) = 0.2, P(X=2) = 0.5, P(X=3) = 0.3, what is the value of the CDF F(2)? :: Answer: 0.7 — F(2) = P(X <= 2) = P(X=1) + P(X=2) = 0.2 + 0.5 = 0.7.
- Week 9 Diagnostic: Which of the following is NOT a property of a valid CDF F(x)? :: Answer: C — A CDF is always non-decreasing and approaches 1 as x -> inf.
Practice & Self-Check
Attempt these diagnostic questions to verify your operational understanding.
1
Question 1
For a discrete random variable X with PMF P(X=1) = 0.2, P(X=2) = 0.5, P(X=3) = 0.3, what is the value of the CDF F(2)?
NAT
3 Unit Assessment
2
Question 2
Which of the following is NOT a property of a valid CDF F(x)?
MCQ
3 Unit Assessment
A. 0 <= F(x) <= 1
B. F(x) is non-decreasing
C. F(x) is strictly decreasing as x -> inf
D. lim_{x -> inf} F(x) = 1