9.4 Discrete Random Variables and Expected Value
The first three sections assigned probabilities to events. Often we also care about a numerical consequence: a score, payout, waiting time, number of errors, or number of successful requests. A random variable connects each outcome to such a number.
A random variable is a function
A random variable is a function whose input is an outcome and whose output is a number. If the sample space is , a real-valued random variable is written
The symbol denotes the set of real numbers. We use it here only to say that outputs such as , , , or are allowed.
The function is fixed; the experiment's outcome is uncertain. That is why the value of is uncertain before the experiment.
Example: number of heads
Toss a coin twice, with
Define to be the number of heads. Then
Different outcomes can map to the same value. In particular, and both map to . A random variable is therefore not merely a relabeling of outcomes; it can collapse several outcomes into one numerical category.
Because takes only separated values , it is a discrete random variable. This chapter studies only discrete random variables.
The probability mass function collects equal values
The probability mass function, abbreviated pmf, gives the probability that equals each possible value. It is defined by
The subscript reminds us which random variable the function describes. The lowercase represents one possible numerical value.
For two fair coin tosses:
| Value | Outcomes mapped to | |
|---|---|---|
A valid pmf obeys two rules:
for every possible , and
The notation means “add the probabilities over every possible value of .” The total is because one of those values must occur.
For any set of numbers , the event contains all outcomes whose assigned value lies in . Its probability is found by adding the corresponding pmf entries:
For example,
Expected value is a probability-weighted average
The expected value of a discrete random variable , written , is
For each possible value, multiply the value by its probability, then add the products. For the number of heads,
Expected value is a long-run average predicted by the model. If the two-toss experiment is repeated many times and all values of are averaged, that average tends to settle near .
An expected value does not have to be a possible outcome. If a fair die shows through , then
even though no roll shows . Think of expectation as a balance point of probability mass, not as a prediction that the next result will equal that number.
Payouts and fair games
Suppose a game costs nothing to enter. A fair die pays credits on a , pays credits on a , and loses credit otherwise. Let be the net payout. Outcomes with the same payout are grouped:
| Net payout | Number of die faces | Contribution | |
|---|---|---|---|
Therefore,
The player gains one credit per play on average in the long run. If the organizer charges an entry fee , the new net variable is . Its expectation is
A game is fair in expected value when the expected net gain is . Here the fair fee is . Fairness in this sense does not mean every player wins equally or that the game has little risk; it refers only to the long-run average net gain.
Assign payouts to the faces of a die and watch equal payouts merge into a pmf. A weighted balance beam locates the expectation, while an entry-fee control turns the same game favorable, fair, or unfavorable without changing its outcome probabilities.
Transforming a random variable
If for fixed numbers and , every possible value of is scaled by and shifted by . Expected value follows the same transformation:
We can see why directly from the definition:
because all pmf probabilities sum to .
Indicator variables turn events into zero-or-one numbers
For an event , its indicator variable is defined by
Here denotes one outcome in . The indicator reports whether occurred.
Its pmf has only two values:
Therefore,
This small identity is powerful: the expected value of an indicator equals the probability of its event.
Linearity of expectation counts successes
For discrete random variables with finite expectations,
This is linearity of expectation. The variables do not need to be independent.
To see its counting use, draw cards without replacement from a set of cards, of which are red. Define
for . Let be the total number of red cards drawn. Then
By symmetry, each position is occupied by a red card with probability . Thus
Linearity now gives
The draws are dependent because taking a red card changes what remains. Nevertheless, expectation still adds. We avoided constructing the full pmf of and counting every three-card selection.
More generally, if counts how many events occur, write
Then
The method is: define one indicator per item or position, express the total count as their sum, replace each indicator expectation by its event probability, and add.
Load a capsule deck with successes, sample without replacement, and watch dependent position indicators switch on or off. Repeated expeditions compare the simulated average count with the exact linearity result, even though later draw probabilities react to earlier draws.
Chapter 9 synthesis
The chapter built one connected probability workflow:
1. Define outcomes, the sample space, and event subsets. 2. Use counting to measure events when outcomes are equally likely. 3. Restrict the space when information arrives, producing conditional probability. 4. Test whether information changes probability, producing independence or dependence. 5. Reverse a condition with Bayes' theorem to update hidden explanations. 6. Map outcomes to numbers with a random variable, then summarize them with a pmf and expected value. 7. Turn event counts into sums of indicators and use linearity of expectation.
Chapter 10 begins the study of trees. The branching diagrams briefly used for conditional routes will become mathematical objects in their own right, with precise properties, traversals, and algorithms.