Session 4: Discrete Random Variables

Movement II: One Random Variable

EE 520: Random Processes (Fall 2026). Instructor: John Lipor.

This is the first meeting of Movement II: One Random Variable. We restate the course slogan, as we will at the start of every movement:

A probability model answers three questions: What is uncertain? What is observed? How should observation change belief and action?

Movement I answered these for a target hiding among cells, where the uncertain thing was a label. Movement II keeps the whole belief–action loop and changes the objects inside it: from here on the uncertain thing is a number. The session thesis: a random variable packages a numerical question about an uncertain world, and expectation is its single-number summary, linear no matter what.

Launch

The search game so far asked where. Now ask how much. How many looks will tomorrow’s search take before the target is found? How many mines will a single sweep of the minefield turn up? How many packets arrive at a relay in the next second? None of these is known in advance, yet each is a definite number once the world reveals itself. A quantity that is a number, but a number determined by the uncertain outcome, is a random variable. Today we build the three tools that tame such quantities: the distribution (what values, with what probabilities), expectation (the one-number summary), and the indicator method (which computes averages of complicated counts without ever writing down their distribution). By the end you will compute, in one line, how much ground a team of uncoordinated searchers covers, a count whose distribution we never write down.

Development

Random variables, PMF, and support

Definition 1 (Random variable). A random variable is a function X:Ω→ℝX : \Omega \to \mathbb{R} that assigns a number X(ω)X(\omega) to each outcome. Every set of values B⊆ℝB \subseteq \mathbb{R} then names an event {X∈B}={ω:X(ω)∈B}\left\{X \in B\right\} = \left\{\omega : X(\omega) \in B\right\}, and XX inherits its probabilities from ℙ\mathbb{P}: ℙ(X∈B)=ℙ({ω:X(ω)∈B})\mathbb{P}(X \in B) = \mathbb{P}(\left\{\omega : X(\omega) \in B\right\}).

(There is a technical condition, that each such set be a legitimate event, which measure theory handles; as promised in Session 1 we will never need it.) A random variable is discrete if it takes values in a finite or countable set. For discrete XX the probabilities collapse to one value at a time.

Definition 2 (Probability mass function and support). The probability mass function (PMF) of a discrete random variable XX is pX(x)=ℙ(X=x)p_X(x) = \mathbb{P}(X = x). Its support is the set of values with pX(x)>0p_X(x) > 0. The PMF is nonnegative and sums to one over the support: ∑xpX(x)=1\sum_x p_X(x) = 1.

Example: tossing a fair coin twice, let XX count the heads. Then Ω={HH,HT,TH,TT}\Omega = \left\{HH, HT, TH, TT\right\}, and reading off the outcomes gives pX(0)=1/4p_X(0) = 1/4, pX(1)=1/2p_X(1) = 1/2, pX(2)=1/4p_X(2) = 1/4. The event “at least one head” is {X≥1}\left\{X \ge 1\right\}, with ℙ(X≥1)=pX(1)+pX(2)=3/4\mathbb{P}(X \ge 1) = p_X(1) + p_X(2) = 3/4: once we have the PMF, probabilities of value-events are just sums.

The CDF: a running total

The PMF answers “what is the probability of exactly xx?” Often we want “at most xx,” and accumulating the PMF gives a function that means what it says at every real number.

Definition 3 (Cumulative distribution function). The cumulative distribution function (CDF) of XX is FX(x)=ℙ(X≤x)F_X(x) = \mathbb{P}(X \le x), defined for every x∈ℝx \in \mathbb{R}.

For a discrete variable FXF_X is a running total of the PMF: it is flat between support points and jumps by pX(xi)p_X(x_i) at each value xix_i, producing a staircase (Figure 1). Three properties hold for any CDF and are worth reading off the staircase: FXF_X is nondecreasing; FX(x)→0F_X(x) \to 0 as x→−∞x \to -\infty and →1\to 1 as x→+∞x \to +\infty; and FXF_X is right-continuous, so the value at a jump is the higher one (the filled dot). The jump height recovers the PMF: pX(xi)=FX(xi)−lim⁡x↑xiFX(x)p_X(x_i) = F_X(x_i) - \lim_{x \uparrow x_i} F_X(x). The CDF is the object that will survive into Session 6, where continuous variables have no PMF but every variable has a CDF.

A discrete random variable’s PMF (top) and its CDF (bottom). The CDF is the running total of the PMF; each jump equals the corresponding mass.

Expectation and LOTUS

Definition 4 (Expectation). The expectation (expected value, mean) of a discrete random variable XX is 𝔼[X]=∑xxpX(x),\begin{equation} \mathbb{E}[X] = \sum_x x\, p_X(x), \end{equation} the sum taken over the support.

Two readings, both correct and neither to be belabored. As a long-run average, 𝔼[X]\mathbb{E}[X] is the value the sample mean of many independent copies of XX settles toward. As a center of mass, 𝔼[X]\mathbb{E}[X] is the balance point of the PMF regarded as weights placed along the number line. The mean of the coin-count above is 0⋅14+1⋅12+2⋅14=10 \cdot \tfrac14 + 1 \cdot \tfrac12 + 2 \cdot \tfrac14 = 1.

To average a function of XX we do not need the distribution of that function; we reweight the values of XX themselves.

Theorem 1 (Law of the unconscious statistician (LOTUS)). For any function g:ℝ→ℝg : \mathbb{R}\to \mathbb{R}, 𝔼[g(X)]=∑xg(x)pX(x).\begin{equation} \mathbb{E}[g(X)] = \sum_x g(x)\, p_X(x). \end{equation}

Proof. Group the outcomes of g(X)g(X) by the value of XX. By definition 𝔼[g(X)]=∑yyℙ(g(X)=y)\mathbb{E}[g(X)] = \sum_y y\, \mathbb{P}(g(X) = y), and ℙ(g(X)=y)=∑x:g(x)=ypX(x)\mathbb{P}(g(X) = y) = \sum_{x : g(x) = y} p_X(x). Substituting and exchanging the order of the finite (or absolutely convergent) sums, 𝔼[g(X)]=∑yy∑x:g(x)=ypX(x)=∑xg(x)pX(x),\begin{equation} \mathbb{E}[g(X)] = \sum_y y \sum_{x : g(x) = y} p_X(x) = \sum_x g(x)\, p_X(x), \end{equation} since for each xx the outer value yy equals g(x)g(x). The point is that we never had to find the PMF of g(X)g(X). ◻

Linearity: the engine of the course

Theorem 2 (Linearity of expectation). For random variables X,YX, Y and constants a,ba, b, 𝔼[aX+bY]=a𝔼[X]+b𝔼[Y].\begin{equation} \mathbb{E}[aX + bY] = a\,\mathbb{E}[X] + b\,\mathbb{E}[Y]. \end{equation}

Proof. Work on the outcome space directly, where XX and YY are ordinary functions of ω\omega. Writing 𝔼[Z]=∑ωZ(ω)ℙ(ω)\mathbb{E}[Z] = \sum_\omega Z(\omega)\,\mathbb{P}(\omega) for a discrete model, 𝔼[aX+bY]=∑ω(aX(ω)+bY(ω))ℙ(ω)=a∑ωX(ω)ℙ(ω)+b∑ωY(ω)ℙ(ω)=a𝔼[X]+b𝔼[Y].\begin{equation} \mathbb{E}[aX + bY] = \sum_\omega \big(aX(\omega) + bY(\omega)\big)\mathbb{P}(\omega) = a\sum_\omega X(\omega)\mathbb{P}(\omega) + b\sum_\omega Y(\omega)\mathbb{P}(\omega) = a\,\mathbb{E}[X] + b\,\mathbb{E}[Y]. \end{equation} No assumption whatsoever was made about how XX and YY relate. ◻

Linearity needs no independence. Theorem 2 holds for any XX and YY: independent or not, correlated or not, same experiment or different. This unconditional freedom is what makes the indicator method below so powerful. We will compute the mean of a complicated count by breaking it into a sum of simple pieces and adding their means, even when the pieces are tangled together, precisely because linearity never asks whether they are.

Indicators: counting by expectation

An indicator of an event AA is the 0/10/1 random variable 𝟙{A}\mathbb{1}\left\{A\right\} that equals 11 when AA occurs and 00 otherwise. Its mean is just the probability of the event: 𝔼[𝟙{A}]=1⋅ℙ(A)+0⋅ℙ(A𝖼)=ℙ(A).\begin{equation} \label{eq:indicator} \mathbb{E}[\mathbb{1}\left\{A\right\}] = 1 \cdot \mathbb{P}(A) + 0 \cdot \mathbb{P}(A^{\mathsf{c}}) = \mathbb{P}(A). \end{equation} This tiny identity, married to linearity, is a counting machine. Whenever a random variable XX counts how many of several events occur, write it as a sum of indicators, X=∑i𝟙{Ai}X = \sum_{i} \mathbb{1}\left\{A_i\right\}, and then 𝔼[X]=∑i𝔼[𝟙{Ai}]=∑iℙ(Ai).\begin{equation} \mathbb{E}[X] = \sum_i \mathbb{E}[\mathbb{1}\left\{A_i\right\}] = \sum_i \mathbb{P}(A_i). \end{equation} The expected count is the sum of the individual event probabilities, with no distribution of XX ever computed and no independence required. The worked examples put this to work on a count whose pieces are tangled together.

Variance and standard deviation

Expectation locates the center; variance measures spread.

Definition 5 (Variance and standard deviation). The variance of XX is Var⁡(X)=𝔼[(X−𝔼[X])2]=𝔼[X2]−(𝔼[X])2\operatorname{Var}(X) = \mathbb{E}\big[(X - \mathbb{E}[X])^2\big] = \mathbb{E}[X^2] - (\mathbb{E}[X])^2, and the standard deviation is σX=Var⁡(X)\sigma_X = \sqrt{\operatorname{Var}(X)}, carried in the same units as XX.

The two expressions agree by expanding the square and using linearity: 𝔼[(X−μ)2]=𝔼[X2]−2μ𝔼[X]+μ2=𝔼[X2]−μ2\mathbb{E}[(X - \mu)^2] = \mathbb{E}[X^2] - 2\mu\mathbb{E}[X] + \mu^2 = \mathbb{E}[X^2] - \mu^2 with μ=𝔼[X]\mu = \mathbb{E}[X]. Variance is not linear; it responds to affine changes by the square of the scale: Var⁡(aX+b)=𝔼[(aX+b−a𝔼[X]−b)2]=𝔼[a2(X−𝔼[X])2]=a2Var⁡(X).\begin{equation} \label{eq:varaffine} \operatorname{Var}(aX + b) = \mathbb{E}\big[(aX + b - a\mathbb{E}[X] - b)^2\big] = \mathbb{E}\big[a^2(X - \mathbb{E}[X])^2\big] = a^2\operatorname{Var}(X). \end{equation} The shift bb drops out (moving the center does not change spread) and the scale aa enters squared.

For a sum, the two-variable expansion shows what independence buys. For any X,YX, Y, Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)+2(𝔼[XY]−𝔼[X]𝔼[Y]),\begin{equation} \label{eq:varsum} \operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y) + 2\big(\mathbb{E}[XY] - \mathbb{E}[X]\mathbb{E}[Y]\big), \end{equation} the last bracket being the cross term. When XX and YY are independent, 𝔼[XY]=𝔼[X]𝔼[Y]\mathbb{E}[XY] = \mathbb{E}[X]\mathbb{E}[Y], so the cross term vanishes and variances add: Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)\operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y). The same cancellation extends to any number of pairwise-independent terms.

Remark 1. We are borrowing one fact on credit: that independence forces 𝔼[XY]=𝔼[X]𝔼[Y]\mathbb{E}[XY] = \mathbb{E}[X]\mathbb{E}[Y]. It is intuitive (the average of a product of unrelated quantities is the product of the averages) and we will prove it properly in Session 8, once joint distributions give us the tools. Everything in this session’s variance computations uses only the vanishing of that cross term.

Worked examples

(a) Uncoordinated search: how much ground is covered?

Ten searchers set out over a field of n=20n = 20 cells. They do not coordinate: each independently picks one cell uniformly at random and searches it. Let CC be the number of distinct cells searched. Had they coordinated, CC would be 1010. How much coverage do they lose by not talking?

The PMF of CC is a genuine chore: it requires counting the ways ten choices can land on exactly cc distinct cells. The indicator method skips it, provided we choose the right pieces. Indicators on the searchers do not help, since whether searcher ss reaches a new cell depends on everyone else’s choices. Put the indicators on the cells instead: let Ij=𝟙{cell j is searched by someone}I_j = \mathbb{1}\left\{\text{cell } j \text{ is searched by someone}\right\}, so that C=∑j=120IjC = \sum_{j=1}^{20} I_j. Cell jj is missed exactly when all ten searchers pick other cells; each does so with probability 19/20=0.9519/20 = 0.95, independently of the others, so ℙ(Ij=1)=1−(0.95)10≈1−0.599=0.401.\begin{equation} \mathbb{P}(I_j = 1) = 1 - (0.95)^{10} \approx 1 - 0.599 = 0.401. \end{equation} By [eq:indicator] and linearity, 𝔼[C]=∑j=120ℙ(Ij=1)=20(1−(0.95)10)≈8.03.\begin{equation} \mathbb{E}[C] = \sum_{j=1}^{20} \mathbb{P}(I_j = 1) = 20\big(1 - (0.95)^{10}\big) \approx 8.03. \end{equation} On average about two of the ten looks are wasted on cells someone else already searched.

Notice what linearity just ignored. The indicators are not independent: there are only ten searchers, so if cells 11 through 99 are all covered, at most one searcher is left for the other eleven cells. Linearity never asked. This is the freedom of Theorem 2 in action: a count whose pieces are tangled together, averaged in one line.

(b) The spread of the coverage count: cross terms that do not vanish

For the variance, expand as in [eq:varsum], now with twenty terms: Var⁡(C)=∑j=120Var⁡(Ij)+∑j≠l(𝔼[IjIl]−𝔼[Ij]𝔼[Il]).\begin{equation} \operatorname{Var}(C) = \sum_{j=1}^{20} \operatorname{Var}(I_j) + \sum_{j \neq l} \big(\mathbb{E}[I_j I_l] - \mathbb{E}[I_j]\,\mathbb{E}[I_l]\big). \end{equation} Each indicator satisfies Ij2=IjI_j^2 = I_j, so Var⁡(Ij)=0.401−0.4012≈0.2403\operatorname{Var}(I_j) = 0.401 - 0.401^2 \approx 0.2403. For the cross terms, the product IjIlI_j I_l is itself an indicator, of the event that both cells are covered, so 𝔼[IjIl]=ℙ(j and l both covered)\mathbb{E}[I_j I_l] = \mathbb{P}(\text{$j$ and $l$ both covered}). Both cells are missed exactly when every searcher picks one of the other 1818 cells, which each does with probability 0.900.90; inclusion–exclusion (Session 1) on the two “missed” events then gives ℙ(j and l both covered)=1−2(0.95)10+(0.90)10≈0.151.\begin{equation} \mathbb{P}(\text{$j$ and $l$ both covered}) = 1 - 2\,(0.95)^{10} + (0.90)^{10} \approx 0.151. \end{equation} Each cross term is therefore 0.151−0.4012≈−0.009810.151 - 0.401^2 \approx -0.00981. It is negative because covering one cell uses up a searcher who might have covered the other. Each one is tiny, but there are 20×19=38020 \times 19 = 380 of them: Var⁡(C)≈20(0.2403)+380(−0.00981)≈4.81−3.73=1.08,σC≈1.04.\begin{equation} \operatorname{Var}(C) \approx 20\,(0.2403) + 380\,(-0.00981) \approx 4.81 - 3.73 = 1.08, \qquad \sigma_C \approx 1.04. \end{equation} Had we treated the indicators as independent and dropped the cross terms, we would have reported a variance of 4.814.81, more than four times too large. Dependence left the mean untouched in (a), but it reshaped the spread: because the searchers form a fixed pool, the coverage count is far more predictable than twenty independent cells would be. Linearity of the mean needs no independence; additivity of variance does, and dependence enters the variance only through the cross terms.

(c) Planning with the average: why 𝔼[g(X)]≠g(𝔼[X])\mathbb{E}[g(X)] \neq g(\mathbb{E}[X])

A search vehicle must cover one unit of distance, and its speed XX depends on the sea state: 11 or 33 units per hour, equally likely. The time taken is g(X)=1/Xg(X) = 1/X. A planner who averages first uses the mean speed 𝔼[X]=2\mathbb{E}[X] = 2 and budgets g(𝔼[X])=1𝔼[X]=12=0.5 hours,\begin{equation} g(\mathbb{E}[X]) = \frac{1}{\mathbb{E}[X]} = \frac{1}{2} = 0.5 \text{ hours}, \end{equation} whereas the expected time, by LOTUS, is 𝔼[g(X)]=12⋅11+12⋅13=23≈0.667 hours,\begin{equation} \mathbb{E}[g(X)] = \tfrac12 \cdot \frac{1}{1} + \tfrac12 \cdot \frac{1}{3} = \frac{2}{3} \approx 0.667 \text{ hours}, \end{equation} a third more than the plan: the slow case costs far more time than the fast case saves. The two disagree, and not by accident: g(x)=1/xg(x) = 1/x is convex on the positive axis, and for convex gg one always has 𝔼[g(X)]≥g(𝔼[X])\mathbb{E}[g(X)] \ge g(\mathbb{E}[X]). That inequality is Jensen’s inequality; we name it and move on. The moral is operational: you may not push an expectation through a nonlinear function. Averaging and transforming do not commute unless gg is affine, the one case where Theorem 2 applies.

Consolidation

Work these in class.

  1. (Indicators, tangled pieces.) A faulty router delivers nn packets in a uniformly random order (all n!n! orders equally likely). Let XX be the number of packets that arrive in their original position. Find 𝔼[X]\mathbb{E}[X] without finding the PMF. Are your indicators independent?
    Answer: X=∑i=1n𝟙{packet i arrives in position i}X = \sum_{i=1}^{n} \mathbb{1}\left\{\text{packet } i \text{ arrives in position } i\right\}, and each indicator has probability 1/n1/n, so 𝔼[X]=n⋅(1/n)=1\mathbb{E}[X] = n \cdot (1/n) = 1 for every nn. The indicators are dependent (if n−1n - 1 packets are in place, so is the last one), and linearity ignores that.

  2. (CDF.) A discrete XX has PMF pX(0),…,pX(3)=(0.2,0.5,0.2,0.1)p_X(0), \dots, p_X(3) = (0.2, 0.5, 0.2, 0.1). Compute FX(1)F_X(1) and ℙ(X≥2)\mathbb{P}(X \ge 2).
    Answer: FX(1)=pX(0)+pX(1)=0.7F_X(1) = p_X(0) + p_X(1) = 0.7; ℙ(X≥2)=1−FX(1)=0.3\mathbb{P}(X \ge 2) = 1 - F_X(1) = 0.3.

  3. (Conceptual.) A relay’s backlog XX is 00 or 1010 packets, each with probability 1/21/2. Compute 𝔼[X]\mathbb{E}[X]. Is the expected value a backlog the relay can ever actually hold? What does this say about reading “expected” as “typical”?
    Answer: 𝔼[X]=5\mathbb{E}[X] = 5, a value XX never takes; the mean is a balance point, not a prediction of any single outcome, so “expected” is not the same as “typical.”

Synthesis

A random variable is the course thesis pointed at a number: what is uncertain is now a numerical quantity, its distribution (PMF or, more durably, CDF) is the full model of it, and expectation compresses that model to one summary. The engine of the session was linearity, which holds with no strings attached, and its partner the indicator method, which turns any count into a sum of event probabilities and computed the expected coverage of ten uncoordinated searchers in a single line, even though the pieces of that count were dependent. Variance then measured the spread, and there, unlike for the mean, independence mattered: it is what makes the cross terms vanish so variances add, and in the coverage count, where it failed, the cross terms cut the variance by more than a factor of four. We also drew the boundary between averaging and transforming: 𝔼[g(X)]≠g(𝔼[X])\mathbb{E}[g(X)] \neq g(\mathbb{E}[X]) except when gg is affine. Next session takes the ad-hoc counts we built by hand and recognizes the recurring shapes among them, the handful of named distributions that model almost every sensor and arrival count, and it meets the first genuinely new tool of Movement II: the CDF method for the distribution of a maximum or a minimum.

Self-check questions

  1. You know a random variable’s PMF. In one sentence each, how do you get (i) its CDF and (ii) the probability of the event {X≥2}\left\{X \ge 2\right\}?
    Answer: (i) FX(x)F_X(x) is the running total ∑xi≤xpX(xi)\sum_{x_i \le x} p_X(x_i); (ii) ℙ(X≥2)=∑xi≥2pX(xi)=1−FX(1)\mathbb{P}(X \ge 2) = \sum_{x_i \ge 2} p_X(x_i) = 1 - F_X(1).

  2. Why can the expected number of cells covered by uncoordinated searchers be computed without the distribution of that count, and why does treating the cell indicators as independent give the right mean but the wrong variance?
    Answer: write the count as a sum of cell indicators and use linearity, which needs no independence; the variance, however, contains the cross terms ℙ(both covered)−ℙ(covered)2\mathbb{P}(\text{both covered}) - \mathbb{P}(\text{covered})^2, which are negative here, so dropping them overstates the spread.

  3. Give a one-line reason 𝔼[1/X]\mathbb{E}[1/X] need not equal 1/𝔼[X]1/\mathbb{E}[X], and name the general principle.
    Answer: 1/x1/x is nonlinear (convex), so averaging and transforming do not commute; Jensen’s inequality gives 𝔼[1/X]≥1/𝔼[X]\mathbb{E}[1/X] \ge 1/\mathbb{E}[X] for positive XX.