OttoLearnOttoLearn

L-PR-4: Discrete Random Variables

Module 3 · Probability Distributions

Introduction

▾

In Québec, an insurer may consider age alongside factors such as driving history, vehicle, location, and how the vehicle is used. The Autorité des marchés financiers describes age as one input among several — not a promise that everyone’s premium drops on a particular birthday. Behind that individualized price is a distribution of possible claim costs: the insurer estimates what many similar policies will cost over time even though any one driver’s result is uncertain.

The concept at work is expected value — the long-run average outcome of a random process, weighted by how likely each outcome is. Insurance companies, casinos, investment funds, and pharmaceutical companies all make decisions by computing expected values. When a drug company evaluates whether to run a clinical trial, expected value is one input to that decision. When a casino sets slot-machine payouts, it sets the player’s expected net winnings below zero.

Learning outcomes

After this lesson, you will be able to:

  • Distinguish between discrete and continuous random variables and interpret the notation , .
  • Construct a probability mass function (PMF) and verify its validity.
  • Compute the expected value and interpret it as a long-run average.
  • Compute the variance and standard deviation using the shortcut formula.

This lesson introduces random variables — functions that attach numbers to random outcomes — and the mathematical tools for describing their behaviour: expected value and variance. In L-PR-1, you assigned probabilities to events; here, you attach a numerical value to every outcome, organize all of those probabilities into a distribution, and summarize the distribution as a whole. That is the bridge from probability rules to statistical models.

Prerequisites

▾
What you will use from earlier
  • Sample space (from L-PR-1): The set of all possible outcomes of a random experiment. You need this to list every value a random variable can take.
  • Classical probability (from L-PR-1): for equally likely outcomes. Here means the same as in L-PR-1: the number of outcomes in . Today we generalize: outcomes can have unequal probabilities, so we use a table instead of counting.
  • Probability axioms (from L-PR-1): for any event , and for the full sample space. The same axioms apply to every row and to the column total in a PMF table.
  • Complement rule (from L-PR-1): . You will use the equivalent idea that the sum of all PMF probabilities must equal 1 to find a missing value.
  • Weighted average (arithmetic): Multiplying each value by its “weight” and summing. Expected value is exactly a weighted average — weights are probabilities.
Retrieval checkpoint · from L-PR-1

One diagnostic before you begin:

Choose one

Checkpoint: If , what is ?

Bridge to today
In L-PR-1

Bridging old and new: In L-PR-1, you computed probabilities for individual events.

Today

Today, you will organize all outcomes into a table (the PMF) and compute a single number — — that summarizes the entire distribution. A key shift: probabilities in a PMF need not be equal, and need not equal any specific outcome in the table.

Core Concepts

▾
Your route through the ideas

Six concepts — here is how they build on each other:

  • C1 — Random Variables: What kind of quantity are we studying?
  • C2 — PMF: How do we record all the probabilities in one place?
  • C3 — Expected Value: What is the long-run average outcome?
  • C4 — E(X²): An intermediate quantity needed for variance.
  • C5 — Variance and SD: How spread out are the outcomes?
  • C6 — CDF: How do we answer “at most” and “at least” questions?

C1 — Random Variables

When you roll a die, you don’t know in advance which face will appear. But the outcome is always a number — 1, 2, 3, 4, 5, or 6. A random variable is a rule that assigns a number to each outcome of a random experiment.

We write to mean a random variable, and (lowercase) to mean one specific value it can take.

Random Variable

A random variable is a function that assigns a real number to each outcome in the sample space of a random experiment.

  • A discrete random variable takes a countable set of values (e.g., 0, 1, 2, 3, …).
  • A continuous random variable takes any value in an interval (e.g., any height between 150 cm and 200 cm).
Example
  • Number of customers who enter a store in one hour → discrete (0, 1, 2, 3, …)
  • Height of a randomly chosen student → continuous (any value in an interval)
  • Number of defective items in a batch of 20 → discrete (0, 1, 2, …, 20)
  • Time until the next earthquake → continuous (any non-negative real number)

Two number lines contrast discrete and continuous random variables. The top line has five labelled dots at integers 0 through 4. The bottom line has a solid band from 150 through 200, with arrowheads showing that every point in the interval is included.

Discrete01234countable, isolated values — number of callsContinuous150200every value in the interval — height in cm
Figure 1. Dots mark isolated values that can be listed; the continuous band includes every point from 150 to 200. Shape as well as colour distinguishes the two variable types.

“Discrete” does not mean “small.” The number of grains of sand on a beach is countable (even if enormous) — in principle it is discrete. The distinction is whether the variable can take any value in an interval (continuous) or only isolated, countable values (discrete).


C2 — Probability Mass Function (PMF)

A PMF is simply a table (or formula) that lists every value that can take, along with the probability of each. Think of it as the complete “probability recipe” for your random variable.

Probability Mass Function (PMF)

The probability mass function of a discrete random variable assigns a probability to each possible value:

A function is a valid PMF if and only if both conditions hold.

A three-step arrow pipeline constructs the PMF for the number of heads in two fair flips: list HH, HT, TH, TT; assign head counts 2, 1, 1, 0; then combine equal counts to obtain probabilities 0.25, 0.50, 0.25.

1 · Sample spaceHH · HTTH · TTfour equally likely outcomes2 · Assign XHH → 2 · HT → 1TH → 1 · TT → 0count heads3 · CombineP(X=0) = 0.25P(X=1) = 0.50P(X=2) = 0.25sum = 1.00 ✓
Figure 2. Constructing a PMF means mapping every sample-space outcome to a numerical value, then combining outcomes with the same value. Here HT and TH both produce , so their probabilities add to 0.50.
Example

= number of heads in two fair coin flips.

012
0.250.500.25

Check: ✓. All probabilities ✓.

A PMF does not require each probability to equal . Outcomes can have unequal probabilities — that is the whole point of building a PMF rather than just counting.

Figure 3. Adjust the final probability until the total is exactly 1.00. The numerical total and validity message supplement the coloured bar, so correctness never depends on colour alone.

Three probabilities are fixed. Adjust until the total bar fills to exactly 1.00 — there is only one value that makes this a valid PMF.

A PMF bar chart has bars labelled 0.10, 0.40, 0.30, and 0.20 at x values 1 through 4. A contrasting dashed line at 2.60 is labelled expected value and balance point. The tallest bar is at 2, so position and line pattern distinguish the mean from the mode.

0.100.400.300.201234xP(X = x)E(X) = 2.60dashed balance line
Figure 4. The expected value 2.60 falls between 2 and 3, while the tallest bar—the mode—is at 2. The orange dashed line and its label identify the balance point without relying on colour alone.

C3 — Expected Value

The expected value answers: “If this random experiment were repeated an enormous number of times, what would the average outcome be?” It is a weighted mean where each outcome is weighted by its probability .

We write to emphasize that the expected value plays the same role as the population mean in descriptive statistics.

Expected Value

The expected value (mean) of a discrete random variable is:

This is the long-run average outcome across infinitely many repetitions of the experiment.

Example

Mini-example: For the PMF in the chart above ( = 1, 2, 3, 4 with = 0.10, 0.40, 0.30, 0.20):

If you repeated this experiment millions of times and averaged all results, the average would approach 2.60.

Figure 5. The balance beam locates from all outcome–probability pairs. Presets show that the balance point can differ from the modal bar.

Try the three preset buttons. In the left-skewed preset, the mode is , but is pulled leftward by the lower-probability outcomes — the balance point is not the tallest bar. Skew is named for the direction of the tail.

E(X) is not the mode. The most likely outcome (mode) is in the example above (probability 0.40). But . The expected value is the balance point of the distribution — it accounts for how far each outcome is from the center, not just which has the highest probability. In fact, E(X) = 3.5 for a fair die, even though no face shows 3.5.

Figure 6. Repeated simulated outcomes make the running average wander at first and then stabilize near the labelled theoretical value .

“Expected value” means the long-run average. Run one trial: the average is that single whole-number outcome — nowhere near 2.60. Keep running trials and watch the running average wander, then settle onto the dashed E(X) line.


C4 — Computing

To compute variance, you first need a related quantity: . This is also a weighted average, but you square each outcome before weighting it.

We write to mean “the expected value of the squared random variable.”

Expected Value of X²

This is computed from the same PMF: square each value, multiply by its probability, and sum.

Example
Continuing the example above:

. In the example, , but . These are equal only when is a constant (no randomness at all). Confusing these two quantities is one of the most common errors when computing variance — it would give , which is wrong.

Two numbered process columns compare square after averaging with square before averaging. The first produces 6.76 and the second 7.60. A not-equal symbol between the labelled results emphasizes that order matters.

[E(X)]²① Average: E(X) = 2.60↓② Square the averageE(X²)① Square: 1, 4, 9, 16↓② Take the weighted average6.767.60≠The two operation orders produce different results.
Figure 7. Averaging first gives ; squaring each outcome before averaging gives . The numbered steps and unequal values distinguish the processes without relying on colour.

C5 — Variance and Standard Deviation

Variance measures how spread out the distribution is — how far a typical outcome is from the expected value. A small variance means most outcomes cluster near ; a large variance means outcomes are spread widely.

We write and .

Variance and Standard Deviation

The variance of a discrete random variable is the expected squared distance from its mean :

Shortcut formula. The same value is usually faster to compute with (Challenge 1 shows why the two agree):

The standard deviation is:

Both measure spread in the same units as (standard deviation) or squared units (variance). Variance is always .

Example
Completing the example:

Interpretation: outcomes of typically deviate from the expected value of 2.60 by about 0.92 units.

Diagram showing why Var(X) measures spread, using the PMF with X equal to 1, 2, 3, 4 and probabilities 0.10, 0.40, 0.30, 0.20, whose mean is 2.60. For each outcome, a horizontal arrow shows its deviation from the mean (minus 1.60, minus 0.60, plus 0.40, plus 1.40), and a square built on that arrow has area equal to the squared deviation (2.56, 0.36, 0.16, 1.96). Each square is shaded in proportion to its probability weight. Variance is the probability-weighted average of these squared distances from the mean: 2.56 times 0.10 plus 0.36 times 0.40 plus 0.16 times 0.30 plus 1.96 times 0.20 equals 0.84, so the standard deviation is about 0.92. Outcomes far from the mean contribute disproportionately because the distance is squared. μ = E(X) = 2.60 x = 1 x − μ = −1.60 (x − μ)² = 2.56 weight P = 0.10 2.56 × 0.10 = 0.256 x = 2 x − μ = −0.60 (x − μ)² = 0.36 weight P = 0.40 0.36 × 0.40 = 0.144 x = 3 x − μ = +0.40 (x − μ)² = 0.16 weight P = 0.30 0.16 × 0.30 = 0.048 x = 4 x − μ = +1.40 (x − μ)² = 1.96 weight P = 0.20 1.96 × 0.20 = 0.392 0.10 0.40 0.30 0.20 1 2 3 4 Var(X) = 2.56(0.10) + 0.36(0.40) + 0.16(0.30) + 1.96(0.20) = 0.256 + 0.144 + 0.048 + 0.392 = 0.84 σ = √0.84 ≈ 0.92

Each square's side is the distance from μ, so its area is the squared deviation (x − μ)². Darker squares carry more probability weight. Variance averages the areas using those weights — outcomes far from μ contribute disproportionately because the distance is squared.

Figure 8. Each outcome’s squared distance from is weighted by its probability. Position, square size, and labels reveal each contribution in addition to colour.

What the formula measures: each outcome’s distance to is squared (the green squares — area = ) and weighted by its probability. Far outcomes contribute disproportionately because the distance is squared.

Two PMF panels share expected value 3. The low-variance panel has three bars near 3 and a narrow bracket labelled standard deviation 0.71. The high-variance panel has five wider-spread bars and a wide bracket labelled standard deviation 1.26. Bar positions, bracket widths, titles, and numerical labels communicate the contrast.

Low variance · σ ≈ 0.71High variance · σ ≈ 1.260.250.500.250.150.200.300.200.151234512345E(X)=3E(X)=3narrow: ±0.71wide: ±1.26
Figure 9. Both distributions are centred at , but the labelled standard-deviation bracket is narrower for the concentrated PMF and wider for the dispersed PMF. Width, bar positions, and values convey the comparison without relying on colour.

Variance is always . If you compute a negative variance, you made an arithmetic error. Since , it is an average of non-negative numbers and cannot be negative. A negative answer is a signal to recheck your arithmetic, not a valid result.


C6 — Cumulative Distribution Function (CDF)

The PMF answers “exactly equal to.” The CDF answers “less than or equal to” — it accumulates the probabilities as increases.

We write to denote the CDF evaluated at .

Cumulative Distribution Function (CDF)

The cumulative distribution function of a discrete random variable is:

The CDF gives the probability that takes a value at most .

To answer “at least ,” subtract all probability below : . In a finite PMF table, subtract the CDF at the last listed value below . If is integer-valued and is an integer, this becomes .

To answer “between and ”: .

Example

CDF for our running example ( = 1, 2, 3, 4):

10.100.10
20.400.50
30.300.80
40.201.00

. .

Figure 10. Moving the control adds one PMF bar at a time and raises the labelled CDF staircase by that bar’s probability, making accumulation visible step by step.

Slide from x = 1 to x = 4 one step at a time. Each step highlights one new bar in the PMF and adds one jump to the staircase. is the height difference between two staircase levels.

Worked Examples

▾

Example 1: Verify a PMF

Example 1 of 4 · Fully worked

A game assigns payouts according to the table below. Verify that this is a valid PMF.

(payout $)−2035
0.200.500.200.10
Solution (fully narrated):

I notice this problem asks me to verify the PMF — that means checking the two conditions, not computing anything else yet.

Condition 1: All probabilities non-negative. I scan the row: 0.20, 0.50, 0.20, 0.10. All are . ✓

Condition 2: Probabilities sum to 1.

Both conditions hold, so this is a valid PMF. I could stop here — the question only asks to verify, not to compute E(X). Resisting the urge to keep calculating is part of reading the question carefully.


Example 2: Compute E(X) for a Payout Scenario

Example 2 of 4 · Partly guided

Using the same PMF from Example 1 (payouts −2, 0, 3, 5 with probabilities 0.20, 0.50, 0.20, 0.10), predict whether will be negative, zero, or positive. Then compute and interpret it in the context of repeated plays.

Try it on your own first, then open the answer. Even a rough try shows you what you already understand.

Show Solution

The expected payout is $0.70 per play. Even though you have a 50% chance of winning nothing and a 20% chance of losing $2, the possibility of winning $3 or $5 tips the average to $0.70 in your favor.

Interpretation: If you played this game 1000 times, you would expect to come out ahead by about 700$ in total.


Example 3: Compute Var(X) Step by Step

Example 3 of 4 · Less guided

Using the same PMF (payouts −2, 0, 3, 5 with probabilities 0.20, 0.50, 0.20, 0.10), compute , , and . State what the standard deviation means for this game.

Try it on your own first, then open the answer.

Show Solution

Step 1: We already know from Example 2.

Step 2: Compute .

Step 3: Apply the shortcut formula.

Step 4: Compute the standard deviation.

Interpretation: The standard deviation is about $2.15, so the distribution has substantial spread around its expected value of $0.70. That is a scale of variability, not a guarantee that most payouts fall within exactly $2.15 of the mean. The game is favourable in the long run but volatile from play to play.


Example 4: Use the CDF (Find the Error)

Example 4 of 4 · On your own

A student is using the PMF from Examples 1–3. They want to find and write:

CDF values: , .

But wait — the student then says “so the answer is ,” and concludes that .

Identify every error in the student’s reasoning. Recompute and from the PMF, verify the interval probability, and explain whether the final equality is true only here or for every discrete distribution.

Try it on your own first, then open the answer.

Show Solution

The student’s CDF levels are wrong because each level must include every outcome at or below its cutoff:

Using the corrected levels:

The student’s two incorrect CDF levels happened to differ by the correct amount. In this distribution, the only supported value in is , so is true for this interval and this PMF.

It is not a general rule. For example:

That interval includes both and , so its probability is not just .

The CDF formula accumulates all outcomes in the interval, not just the endpoint.

Guided Practice

▾

Problem 1 — Classify a Random Variable (C1)

Choose one

Problem 2 — Test a PMF (C2)

Choose one

Problem 3 — Find the Long-Run Average (C3)

Work it step by step

Problem 4 — Measure Distribution Spread (C4 + C5)

Work it step by step

Independent Practice

▾

Problem 1 — Summarize a Distribution (C2 + C3 + C4 + C5)

Work it step by step

Problem 2 — Read Cumulative Probability (C6)

Work it step by step

Problem 3 — Evaluate a Game and Diagnose Reasoning (C3 + C5)

Work it step by step
Find the first wrong step

Problem 4 — Complete a PMF and Find Its Mean (C2 + C3)

Work it step by step

Problem 5 — Compare Centre and Spread (C3 + C5)

Work it step by step

Problem 6 — Synthesize a Full Distribution Analysis (C2 + C3 + C4 + C5 + C6)

Work it step by step

Problem 7 — Expected Value in a New Setting (C2 + C3)

Type your answer

Problem 8 — Error Analysis (C4 + C5)

Find the first wrong step

Mixed review from L-PR-2 and L-PR-3

Try these without looking back. Pulling an idea out of memory makes it stick better than reading it again.

Review Problem 1 — Conditional probability from a table

Work it step by step

Review Problem 2 — Combinations in a probability calculation

Work it step by step

Mastery Check

▾

Part 1: Skill checks

Each check question draws a new version every time. Two right in a row, on the first try and without help, makes it ready.

Recall: an expected value (C3)

Work it step by step

Question 1 — Discrete or continuous (C1)

Check · C1

Choose one

Question 2 — Completing a PMF (C2)

Check · C2

Try it yourself first, steps after

Question 3 — An expected value (C3)

Check · C3

Try it yourself first, steps after

Question 4 — The spread of a distribution (C4 + C5)

Check · C4 + C5

Try it yourself first, steps after

Question 5 — Reading a CDF (C6)

Check · C6

Try it yourself first, steps after

Part 2: Applied problem

Pick one mission. It counts when every step is right on the first try, with no step shown.

Carnival Decision

Decide whether a ring-toss game is a good deal for a player and support the recommendation quantitatively.

Payout Design

Check whether a proposed payout scheme meets its centre and spread requirements.

Your verdict

Not yet

  • C1: a random variable, discrete or continuous
  • C2: a probability mass function, whose probabilities add to 1
  • C3: the expected value,
  • C4:
  • C5: the variance and the standard deviation, its square root
  • C6: the CDF, , and the probabilities it gives

What to do

    This verdict is not saved, so it starts again when you reload the page.

    Part 3: Explain it (optional)

    Feynman Test

    Explain, in your own words and without formulas, why the expected value need not be the most likely value of a random variable. Use one concrete example and identify both its expected value and its most likely outcome.

    Explain it in your own words first, then compare with the model answer.

    Compare with a model answer

    Expected value is a probability-weighted average, so both the likelihood and size of every outcome affect it. The mode asks a different question: which single outcome has the greatest probability?

    For a fair six-sided die, each face is equally likely, so every value from 1 through 6 is a mode. The expected value is

    The mean lies between possible outcomes. It describes the long-run average of many rolls, not the result of one roll and not the height of the tallest PMF bar.

    If you chose a mission above, also answer its written tasks before you open the examples.

    Carnival Decision.

    A carnival game costs $5 to play. You throw one ring. The prizes and probabilities are:

    OutcomePrizeProbability
    Red bottle$200.05
    Blue bottle$100.15
    Yellow bottle$30.30
    Miss$00.50

    Let be the player’s net winnings: prize minus the $5 fee.

    Task 1. Represent all possible net outcomes and verify that the representation is valid.


    Task 2. Decide whether the game is favourable, unfavourable, or fair for the player in the long run. Choose and show the calculation that supports the decision.


    Task 3. Quantify how much one play can vary around its long-run average. Show the quantities you chose and round the final spread measure to two decimals.


    Task 4. On paper or in your notes, answer a friend who says, “Missing is the most common result, so that fact alone proves this is a bad deal.” Give a two- or three-sentence recommendation that uses both centre and spread, and explain whether uncertainty changes the recommendation.

    Try it on your own first, then open the answer.

    Show Solution

    The net-outcome PMF is:

    155−2−5
    0.050.150.300.50

    Every probability is non-negative, and

    The long-run average is

    The player therefore loses $1.60 per play on average, so the game is unfavourable.

    For spread:

    A strong response to the friend is: “The most common outcome is a $5 loss, but the recommendation should come from the entire distribution. The mean loss is $1.60 per play and the standard deviation is about $5.11, so individual plays are unpredictable, but that variability does not overturn the negative long-run average.”

    Reflection feedback: If your recommendation used only the mode, add the weighted effect of every outcome. If it used only the mean, add what the standard deviation says about play-to-play uncertainty.

    Payout Design.

    Design a PMF for a payout scheme with exactly four distinct outcomes satisfying all of these constraints:

    • Every outcome is a positive integer number of dollars.
    • Every probability is positive, and the probabilities sum to 1.
    • The expected payout is $2.
    • The variance is at least 1.2, so the payouts vary enough to feel exciting.

    Starting idea: start from the values 1 to 4 and adjust the probabilities. Put enough weight on 1 to pull the mean down to $2, then check the spread.

    Task 1. Choose four outcomes and probabilities. Explain the strategy behind your choices without assuming in advance that they work.


    Task 2. Verify every support and probability constraint, then justify whether the centre requirement is met.


    Task 3. Verify whether the spread requirement is met. If it is not, revise the design and recheck every constraint.


    Task 4. On paper or in your notes, explain in two or three sentences what the centre and standard deviation of your final product mean to a customer. Avoid promising that a daily payout will be close to the mean.

    Try it on your own first, then open the answer.

    Show Solution

    Many answers are possible. A natural first attempt keeps most of the weight near $2:

    1234
    0.350.400.150.10

    The four outcomes are distinct positive integers. Every probability is positive, and

    The expected payout is

    For spread:

    Since , the spread requirement fails. Revise: move probability away from $2 toward both ends, 1 and 4, rebalancing so the mean stays at $2:

    1234
    0.500.200.100.20

    Recheck every constraint. The outcomes are unchanged, every probability is positive, and

    A customer-friendly explanation is: “Across many days, the average payout would approach $2 per day. The standard deviation of about $1.18 describes the distribution’s spread; it does not guarantee that a particular day will land within $1.18 of $2.”

    Reflection feedback: If your design used 0 as an outcome, replace it because 0 is not positive. If your interpretation predicted where most individual payouts must fall, revise it to describe the long-run centre and spread without a mean-plus-or-minus-standard-deviation guarantee.

    How was this lesson?

    Optional and anonymous: tap one, or skip it.

    Challenge Problems

    ▾
    Optional stretch

    These go beyond the lesson objectives. Attempt them when you feel confident with the core material.

    Challenge 1 — Derive the Shortcut Formula

    The definition of variance is:

    where . Starting from this definition, derive the shortcut formula by algebraic expansion.

    Try it on your own first, then open the answer.

    Show Derivation

    Starting idea: Expand as a polynomial, then use linearity of expectation.

    Expand the square:

    Apply linearity of expectation (, and for constant ):

    Substitute :

    Since :

    This derivation also explains why always: since variance is defined as an expected value of a squared quantity , it can never be negative, which forces .

    Bonus: What does mean? By definition, . Since always, this expectation equals zero only if with probability 1, meaning with probability 1. A random variable with is a constant — it always takes the same value.


    Challenge 2 — Transform Centre and Spread

    Type your answer

    This regenerable challenge transfers the lesson to a transformed random variable. Solve each new scenario from the definitions and use the feedback to compare how a linear transformation changes centre and spread.

    Show the general derivation

    For constants and , let .

    First find the transformed mean:

    Then apply the definition of variance:

    Substitute and :

    Factor out :

    Therefore,

    Adding shifts every outcome without changing spread. Multiplying by scales every distance from the mean by , so .

    Quick Reference

    ▾
    Strategy advice for E(X) and Var(X) problems
    • Always verify the PMF first (non-negative, sum = 1) before computing anything.
    • Use a table layout: column for , column for , column for , column for . Sum the last two columns to get and in one pass.
    • Never skip computing separately — computing instead is the most common error in this chapter (squaring the mean instead of averaging the squares).
    • A negative variance is always an arithmetic error. Stop and recheck before continuing.
    • For CDF problems, build the full CDF table once, then read off any probability you need.
    Quick-Reference Formulas
    FormulaMeaning
    PMF validity — probabilities must sum to 1
    Expected value — the long-run average
    Second moment — needed for the variance shortcut
    Variance — spread around the expected value
    Standard deviation — spread in original units
    CDF — cumulative probability up to
    “At least ” via the complement; for integer-valued and integer , this is
    “Between and ” via CDF subtraction

    Step-by-Step Computation Workflow

    StepActionFormula
    1Verify the PMFCheck all and
    2Compute
    3Compute
    4Compute Var(X)
    5Compute
    6Build CDF if neededAccumulate PMF values from left to right