variance-covariance-and-common-distributions.html

Lecture 4: Variance, Covariance, and Common Discrete Distributions

EECS 126 (UC Berkeley) · Spring 2026 · January 29, 2026

Reading: Bertsekas & Tsitsiklis, Ch. 2; §4.2–4.3. Ch. 3 next week.

These are my personal notes from Professor Kannan Ramchandran’s EECS 126 (Probability and Random Processes) course at UC Berkeley.

Last lecture we defined expectation and variance for a single random variable. In this lecture we study how variance behaves for sums of random variables, which leads to covariance and the correlation coefficient. We then compute the mean and variance of the four workhorse discrete distributions (Bernoulli, binomial, geometric, Poisson), apply these to the coupon collector problem, prove the memoryless property of the geometric distribution, study how Poisson random variables merge and split, and finally introduce conditional expectation.

Variance of Sums and Covariance

Recall from Lecture 3 the two forms of the variance,

Var⁡(X)=E[(X−E[X])2]=E[X2]−(E[X])2,\Var(X) = \EE\bigl[(X - \EE[X])^2\bigr] = \EE[X^2] - (\EE[X])^2,

and the scaling property

Var⁡(aX+c)=a2 Var⁡(X).\Var(aX + c) = a^2\,\Var(X).

Shifts by a constant cc are not recorded in variance calculations: shifting every outcome by cc moves the mean by cc as well, so the deviations X−E[X]X - \EE[X] are unchanged.

The natural next question is: what is the variance of a sum X+YX + Y? Unlike the mean, the answer depends on how XX and YY interact.

Theorem 4.1 (Variance of a sum)

For any random variables X,YX, Y with finite variances,

Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)+2(E[XY]−E[X] E[Y]).(4.3)\Var(X + Y) = \Var(X) + \Var(Y) + 2\bigl(\EE[XY] - \EE[X]\,\EE[Y]\bigr). \tag{4.3}
Proof. Var⁡(X+Y)=E[(X+Y)2]−(E[X+Y])2=E[X2+2XY+Y2]−(E[X]+E[Y])2=E[X2]+2 E[XY]+E[Y2]−(E[X])2−2 E[X] E[Y]−(E[Y])2=E[X2]−(E[X])2⏟Var⁡(X)  +  E[Y2]−(E[Y])2⏟Var⁡(Y)  +  2 E[XY]−2 E[X] E[Y]=Var⁡(X)+Var⁡(Y)+2(E[XY]−E[X] E[Y]).\begin{aligned} \Var(X+Y) &= \EE\bigl[(X+Y)^2\bigr] - \bigl(\EE[X+Y]\bigr)^2 \\ &= \EE\bigl[X^2 + 2XY + Y^2\bigr] - \bigl(\EE[X] + \EE[Y]\bigr)^2 \\ &= \EE[X^2] + 2\,\EE[XY] + \EE[Y^2] - (\EE[X])^2 - 2\,\EE[X]\,\EE[Y] - (\EE[Y])^2 \\ &= \underbrace{\EE[X^2] - (\EE[X])^2}_{\Var(X)} \;+\; \underbrace{\EE[Y^2] - (\EE[Y])^2}_{\Var(Y)} \;+\; 2\,\EE[XY] - 2\,\EE[X]\,\EE[Y] \\ &= \Var(X) + \Var(Y) + 2\bigl(\EE[XY] - \EE[X]\,\EE[Y]\bigr). \end{aligned}

No independence was used. The derivation above holds for any XX and YY. Independence only enters at the very end, where it makes the cross term vanish (Corollary 4.1 below).

The cross term in (4.3) is important enough to get its own name.

Definition 4.1 (Covariance)

The covariance of random variables XX and YY is

Cov⁡(X,Y)≜E[(X−E[X])(Y−E[Y])]=E[XY]−E[X] E[Y].\Cov(X, Y) \triangleq \EE\bigl[(X - \EE[X])(Y - \EE[Y])\bigr] = \EE[XY] - \EE[X]\,\EE[Y].

In particular, Cov⁡(X,X)=Var⁡(X)\Cov(X, X) = \Var(X). With this notation,

Var⁡(X+Y)=Var⁡(X)+Var⁡(Y)+2 Cov⁡(X,Y).\Var(X + Y) = \Var(X) + \Var(Y) + 2\,\Cov(X, Y).
Equivalence of the two forms.

Write μX=E[X]\mu_X = \EE[X] and μY=E[Y]\mu_Y = \EE[Y], which are constants. Expanding the product and using linearity,

E[(X−μX)(Y−μY)]=E[XY−μYX−μXY+μXμY]=E[XY]−μY E[X]−μX E[Y]+μXμY=E[XY]−μYμX−μXμY+μXμY=E[XY]−μXμY.\begin{aligned} \EE\bigl[(X - \mu_X)(Y - \mu_Y)\bigr] &= \EE\bigl[XY - \mu_Y X - \mu_X Y + \mu_X\mu_Y\bigr] \\ &= \EE[XY] - \mu_Y\,\EE[X] - \mu_X\,\EE[Y] + \mu_X\mu_Y \\ &= \EE[XY] - \mu_Y\mu_X - \mu_X\mu_Y + \mu_X\mu_Y \\ &= \EE[XY] - \mu_X\mu_Y. \end{aligned}

Interpreting the sign. Cov⁡(X,Y)>0\Cov(X,Y) > 0 means XX and YY tend to be above their means together (and below their means together). Cov⁡(X,Y)<0\Cov(X,Y) < 0 means when one is above its mean, the other tends to be below. For a sum, positive covariance inflates the spread and negative covariance dampens it.

Corollary 4.1 (Independent summands)

If X⊥YX \perp Y, then Cov⁡(X,Y)=0\Cov(X, Y) = 0, and therefore

Var⁡(X+Y)=Var⁡(X)+Var⁡(Y).\Var(X + Y) = \Var(X) + \Var(Y).
Proof.

In Lecture 3 we proved that X⊥YX \perp Y implies E[XY]=E[X] E[Y]\EE[XY] = \EE[X]\,\EE[Y]. Hence Cov⁡(X,Y)=E[XY]−E[X] E[Y]=0\Cov(X,Y) = \EE[XY] - \EE[X]\,\EE[Y] = 0, and the cross term in (4.3) vanishes.

Corollary 4.2 (Variance of a sum of many random variables)

For random variables X1,…,XnX_1, \ldots, X_n with finite variances,

Var⁡(∑i=1nXi)=∑i=1nVar⁡(Xi)+2∑i<jCov⁡(Xi,Xj).\Var\Bigl(\sum_{i=1}^n X_i\Bigr) = \sum_{i=1}^n \Var(X_i) + 2\sum_{i<j} \Cov(X_i, X_j).

In particular, if the XiX_i are independent (in fact, pairwise uncorrelated is enough), then

Var⁡(∑i=1nXi)=∑i=1nVar⁡(Xi).\Var\Bigl(\sum_{i=1}^n X_i\Bigr) = \sum_{i=1}^n \Var(X_i).
Proof.

Let μi=E[Xi]\mu_i = \EE[X_i]. Since E[∑iXi]=∑iμi\EE[\sum_i X_i] = \sum_i \mu_i, the centered sum is ∑i(Xi−μi)\sum_i (X_i - \mu_i). Squaring a sum gives a double sum over all pairs (i,j)(i, j):

Var⁡(∑iXi)=E[(∑i(Xi−μi))2]=E[∑i∑j(Xi−μi)(Xj−μj)]=∑i∑jCov⁡(Xi,Xj).\begin{aligned} \Var\Bigl(\sum_{i} X_i\Bigr) &= \EE\Bigl[\Bigl(\sum_{i} (X_i - \mu_i)\Bigr)^2\Bigr] = \EE\Bigl[\sum_{i}\sum_{j} (X_i - \mu_i)(X_j - \mu_j)\Bigr] \\ &= \sum_{i}\sum_{j} \Cov(X_i, X_j). \end{aligned}

The diagonal terms i=ji = j give Cov⁡(Xi,Xi)=Var⁡(Xi)\Cov(X_i, X_i) = \Var(X_i). The off-diagonal terms come in symmetric pairs, Cov⁡(Xi,Xj)=Cov⁡(Xj,Xi)\Cov(X_i, X_j) = \Cov(X_j, X_i), so they contribute 2∑i<jCov⁡(Xi,Xj)2\sum_{i<j}\Cov(X_i,X_j). If every pair is uncorrelated, all off-diagonal terms are zero.

Uncorrelated does not imply independent. Covariance only detects linear dependence. For example, let XX be uniform on {−1,0,1}\{-1, 0, 1\} and Y=X2Y = X^2. Then E[X]=0\EE[X] = 0 and E[XY]=E[X3]=13(−1)+13(0)+13(1)=0\EE[XY] = \EE[X^3] = \tfrac13(-1) + \tfrac13(0) + \tfrac13(1) = 0, so Cov⁡(X,Y)=0−0⋅E[Y]=0\Cov(X, Y) = 0 - 0 \cdot \EE[Y] = 0. But YY is completely determined by XX: for instance P(Y=0∣X=0)=1≠13=P(Y=0)\PP(Y = 0 \mid X = 0) = 1 \ne \tfrac13 = \PP(Y = 0). This was a question Ramchandran asked us at end of previous lecture.

The Correlation Coefficient

Covariance has units (units of XX times units of YY), so its size alone does not tell us how strongly two variables are related. Normalizing by the standard deviations removes the units.

Definition 4.2 (Correlation coefficient)

For random variables X,YX, Y with Var⁡(X)>0\Var(X) > 0 and Var⁡(Y)>0\Var(Y) > 0, the correlation coefficient is

ρ(X,Y)≜Cov⁡(X,Y)Var⁡(X) Var⁡(Y).\rho(X, Y) \triangleq \frac{\Cov(X, Y)}{\sqrt{\Var(X)}\,\sqrt{\Var(Y)}}.

Ramchandran’s vector analogy. Think of random variables as vectors, with “dot product” ⟨U,V⟩=E[UV]\langle U, V\rangle = \EE[UV] and “length” E[U2]\sqrt{\EE[U^2]}. For the centered variables U=X−E[X]U = X - \EE[X] and V=Y−E[Y]V = Y - \EE[Y]:

  • the dot product is E[UV]=Cov⁡(X,Y)\EE[UV] = \Cov(X, Y);
  • the lengths are E[U2]=Var⁡(X)\sqrt{\EE[U^2]} = \sqrt{\Var(X)} and E[V2]=Var⁡(Y)\sqrt{\EE[V^2]} = \sqrt{\Var(Y)}.

So ρ\rho plays the role of cos⁡θ=u⋅v∣u∣ ∣v∣\cos\theta = \dfrac{u \cdot v}{|u|\,|v|}, the cosine of the angle between two vectors. For ordinary vectors, the Cauchy–Schwarz inequality ∣u⋅v∣≤∣u∣ ∣v∣|u \cdot v| \le |u|\,|v| forces −1≤cos⁡θ≤1-1 \le \cos\theta \le 1. The same inequality, proved for random variables below, forces −1≤ρ≤1-1 \le \rho \le 1.

Lemma 4.1 (Cauchy–Schwarz inequality for random variables)

For any random variables U,VU, V with E[U2]<∞\EE[U^2] < \infty and E[V2]<∞\EE[V^2] < \infty,

(E[UV])2≤E[U2] E[V2].\bigl(\EE[UV]\bigr)^2 \le \EE[U^2]\,\EE[V^2].
Proof.

Case 1: E[V2]=0\EE[V^2] = 0. Since V2≥0V^2 \ge 0 and its mean is 00, we must have V=0V = 0 with probability 11. Then UV=0UV = 0 with probability 11, so E[UV]=0\EE[UV] = 0 and both sides equal 00.

Case 2: E[V2]>0\EE[V^2] > 0. For every real number tt, the random variable (U−tV)2(U - tV)^2 is nonnegative, so its expectation is nonnegative. Expanding with linearity:

0≤E[(U−tV)2]=E[U2]−2t E[UV]+t2 E[V2].0 \le \EE\bigl[(U - tV)^2\bigr] = \EE[U^2] - 2t\,\EE[UV] + t^2\,\EE[V^2].

This holds for every tt, so choose the tt that minimizes the right-hand side, namely t⋆=E[UV]/E[V2]t^\star = \EE[UV]/\EE[V^2]. Substituting,

0≤E[U2]−2 E[UV]E[V2] E[UV]+(E[UV])2(E[V2])2 E[V2]=E[U2]−2 (E[UV])2E[V2]+(E[UV])2E[V2]=E[U2]−(E[UV])2E[V2].\begin{aligned} 0 &\le \EE[U^2] - 2\,\frac{\EE[UV]}{\EE[V^2]}\,\EE[UV] + \frac{(\EE[UV])^2}{(\EE[V^2])^2}\,\EE[V^2] \\ &= \EE[U^2] - 2\,\frac{(\EE[UV])^2}{\EE[V^2]} + \frac{(\EE[UV])^2}{\EE[V^2]} \\ &= \EE[U^2] - \frac{(\EE[UV])^2}{\EE[V^2]}. \end{aligned}

Multiplying both sides by E[V2]>0\EE[V^2] > 0 gives (E[UV])2≤E[U2] E[V2](\EE[UV])^2 \le \EE[U^2]\,\EE[V^2].

Theorem 4.2 (Range of the correlation coefficient)

Whenever ρ(X,Y)\rho(X, Y) is defined,

−1≤ρ(X,Y)≤1.-1 \le \rho(X, Y) \le 1.
Proof.

Apply Cauchy–Schwarz to the centered variables U=X−E[X]U = X - \EE[X] and V=Y−E[Y]V = Y - \EE[Y]. By definition, E[UV]=Cov⁡(X,Y)\EE[UV] = \Cov(X,Y), E[U2]=Var⁡(X)\EE[U^2] = \Var(X), and E[V2]=Var⁡(Y)\EE[V^2] = \Var(Y), so

(Cov⁡(X,Y))2≤Var⁡(X) Var⁡(Y).\bigl(\Cov(X,Y)\bigr)^2 \le \Var(X)\,\Var(Y).

Taking square roots, ∣Cov⁡(X,Y)∣≤Var⁡(X)Var⁡(Y)|\Cov(X,Y)| \le \sqrt{\Var(X)}\sqrt{\Var(Y)}. Dividing by the (positive) right-hand side gives ∣ρ(X,Y)∣≤1|\rho(X,Y)| \le 1.

Extreme and zero values. ∣ρ∣=1|\rho| = 1 exactly when equality holds in Cauchy–Schwarz, which happens when U−t⋆V=0U - t^\star V = 0 with probability 11, i.e. when YY is an exact linear function Y=aX+bY = aX + b of XX (with ρ=+1\rho = +1 if a>0a > 0 and ρ=−1\rho = -1 if a<0a < 0). At the other end, ρ=0\rho = 0 means uncorrelated, which, as we just saw, is weaker than independent.

Mean and Variance of Common Distributions

We now compute E[X]\EE[X] and Var⁡(X)\Var(X) for the four distributions introduced in Lecture 3. A recurring theme: the direct sums are often messy, and a better representation of the random variable makes the computation easy.

Bernoulli

Theorem 4.3 (Bernoulli mean and variance)

If X∼Bernoulli⁡(p)X \sim \Bern(p), then

E[X]=p,Var⁡(X)=p(1−p).\EE[X] = p, \qquad \Var(X) = p(1-p).
Proof.

XX takes only the values 00 and 11, with P(X=1)=p\PP(X=1) = p and P(X=0)=1−p\PP(X=0) = 1-p.

E[X]=1⋅P(X=1)+0⋅P(X=0)=1⋅p+0=p.\EE[X] = 1 \cdot \PP(X = 1) + 0 \cdot \PP(X = 0) = 1 \cdot p + 0 = p.

For the second moment, by LOTUS,

E[X2]=∑xx2 P(X=x)=12⋅P(X=1)+02⋅P(X=0)=p.\EE[X^2] = \sum_{x} x^2\,\PP(X = x) = 1^2 \cdot \PP(X = 1) + 0^2 \cdot \PP(X = 0) = p.

Therefore

Var⁡(X)=E[X2]−(E[X])2=p−p2=p(1−p).\Var(X) = \EE[X^2] - (\EE[X])^2 = p - p^2 = p(1-p).

Binomial

Theorem 4.4 (Binomial mean and variance)

If X∼Binomial⁡(n,p)X \sim \Bin(n, p), then

E[X]=np,Var⁡(X)=np(1−p).\EE[X] = np, \qquad \Var(X) = np(1-p).

The direct approach is

E[X]=∑x=0nx⋅P(X=x)=∑x=0nx(nx)px(1−p)n−x,\EE[X] = \sum_{x=0}^{n} x \cdot \PP(X = x) = \sum_{x=0}^{n} x \binom{n}{x} p^x (1-p)^{n-x},

which is doable but unpleasant. Instead, think of the binomial as a sum of nn Bernoulli trials.

Proof.

Let Xi=1{trial i is a success}X_i = \mathbf{1}\{\text{trial } i \text{ is a success}\} for i=1,…,ni = 1, \ldots, n. Each Xi∼Bernoulli⁡(p)X_i \sim \Bern(p), the XiX_i are independent (the trials are independent), and the total number of successes is

X=X1+X2+⋯+Xn.X = X_1 + X_2 + \cdots + X_n.

Mean. By linearity of expectation (which needs no independence),

E[X]=∑i=1nE[Xi]=∑i=1np=np.\EE[X] = \sum_{i=1}^{n} \EE[X_i] = \sum_{i=1}^{n} p = np.

Variance. Because the XiX_i are independent, Corollary 4.2 lets us add the variances:

Var⁡(X)=∑i=1nVar⁡(Xi)=∑i=1np(1−p)=np(1−p).\Var(X) = \sum_{i=1}^{n} \Var(X_i) = \sum_{i=1}^{n} p(1-p) = np(1-p).

Applying direct sum gives us the same result: Using the identity x(nx)=n(n−1x−1)x\binom{n}{x} = n\binom{n-1}{x-1} for x≥1x \ge 1 (the x=0x = 0 term is zero),

E[X]=∑x=1nn(n−1x−1)px(1−p)n−x=np∑x=1n(n−1x−1)px−1(1−p)(n−1)−(x−1)=np∑j=0n−1(n−1j)pj(1−p)(n−1)−j=np (p+(1−p))n−1=np,\begin{aligned} \EE[X] &= \sum_{x=1}^{n} n\binom{n-1}{x-1} p^x (1-p)^{n-x} = np \sum_{x=1}^{n} \binom{n-1}{x-1} p^{x-1}(1-p)^{(n-1)-(x-1)} \\ &= np \sum_{j=0}^{n-1} \binom{n-1}{j} p^{j}(1-p)^{(n-1)-j} = np\,\bigl(p + (1-p)\bigr)^{n-1} = np, \end{aligned}

where we substituted j=x−1j = x - 1 and used the binomial theorem. The indicator method reaches the same answer with far less algebra.

Geometric

Recall that X∼Geometric⁡(p)X \sim \Geom(p) counts the number of independent trials up to and including the first success:

pX(k)=P(X=k)=(1−p)k−1 p,k=1,2,3,…p_X(k) = \PP(X = k) = (1-p)^{k-1}\,p, \qquad k = 1, 2, 3, \ldots

Reading the PMF. Here kk marks the trial on which the first Success occurs (k=Sk = S). So pX(k)p_X(k) is the probability that the first success happens on trial kk: the first k−1k - 1 trials are failures (probability (1−p)k−1(1-p)^{k-1}) and trial kk is a success (probability pp). Note that pX(k)p_X(k) is not the probability of kk successes; a geometric random variable always records exactly one success, and kk counts how long we waited for it.

Definition 4.3 (Survival function)

For an integer-valued random variable XX, the survival function (or tail) is k↦P(X>k)k \mapsto \PP(X > k). For X∼Geometric⁡(p)X \sim \Geom(p),

P(X>k)=(1−p)k,k=0,1,2,…(4.27)\PP(X > k) = (1-p)^k, \qquad k = 0, 1, 2, \ldots \tag{4.27}
Proof.

The event {X>k}\{X > k\} means “no success in the first kk trials,” i.e. we tried kk times and failed every time. The trials are independent and each fails with probability 1−p1-p, so P(X>k)=(1−p)⋯(1−p)⏟k times=(1−p)k\PP(X > k) = \underbrace{(1-p)\cdots(1-p)}_{k \text{ times}} = (1-p)^k.

Theorem 4.5 (Geometric mean)

If X∼Geometric⁡(p)X \sim \Geom(p) with 0<p≤10 < p \le 1, then

E[X]=1p.\EE[X] = \frac{1}{p}.

The direct sum E[X]=∑k=1∞k(1−p)k−1p\EE[X] = \sum_{k=1}^\infty k(1-p)^{k-1}p requires a trick. A better method is the tail sum formula from Lecture 3, which applies because XX takes values in the nonnegative integers.

Proof.

By the tail sum formula,

E[X]=∑k=1∞P(X≥k).\EE[X] = \sum_{k=1}^{\infty} \PP(X \ge k).

For integer-valued XX, {X≥k}={X>k−1}\{X \ge k\} = \{X > k - 1\}. Substituting j=k−1j = k - 1 (so jj runs from 00 to ∞\infty),

E[X]=∑k=1∞P(X>k−1)=∑j=0∞P(X>j).\EE[X] = \sum_{k=1}^{\infty} \PP(X > k-1) = \sum_{j=0}^{\infty} \PP(X > j).

Now plug in the survival function (4.27):

E[X]=∑j=0∞(1−p)j.\EE[X] = \sum_{j=0}^{\infty} (1-p)^j.

This is a geometric series ∑j≥0xj\sum_{j \ge 0} x^j with ratio x=1−px = 1 - p. Since 0<p≤10 < p \le 1 we have ∣x∣<1|x| < 1, so the series converges to 1/(1−x)1/(1-x):

E[X]=11−(1−p)=1p.\EE[X] = \frac{1}{1 - (1-p)} = \frac{1}{p}.

Exam note: tail sum formula will be on exam. For a random variable XX taking values in {0,1,2,…}\{0, 1, 2, \ldots\},

E[X]=∑k=1∞P(X≥k)=∑k=0∞P(X>k).\EE[X] = \sum_{k=1}^{\infty} \PP(X \ge k) = \sum_{k=0}^{\infty} \PP(X > k).

It expresses the mean as the sum of the tail probabilities. It follows from writing X=∑k=1∞1{X≥k}X = \sum_{k=1}^{\infty} \mathbf{1}\{X \ge k\} and taking expectations of both sides.

The direct sum, for comparison. Differentiating the geometric series ∑k≥0xk=11−x\sum_{k\ge0} x^k = \frac{1}{1-x} term by term (valid for ∣x∣<1|x|<1) gives ∑k≥1kxk−1=1(1−x)2\sum_{k\ge1} k x^{k-1} = \frac{1}{(1-x)^2}. With x=1−px = 1-p,

E[X]=p∑k=1∞k(1−p)k−1=p⋅1(1−(1−p))2=p⋅1p2=1p.\EE[X] = p\sum_{k=1}^{\infty} k(1-p)^{k-1} = p \cdot \frac{1}{(1-(1-p))^2} = p \cdot \frac{1}{p^2} = \frac{1}{p}.

The variance of the geometric is derived in Section 4.5, using the memoryless property.

Poisson

Theorem 4.6 (Poisson mean and variance)

If X∼Poisson⁡(λ)X \sim \Pois(\lambda), so that pX(k)=e−λλkk!p_X(k) = \dfrac{e^{-\lambda}\lambda^k}{k!} for k=0,1,2,…k = 0, 1, 2, \ldots, then

E[X]=λ,Var⁡(X)=λ.\EE[X] = \lambda, \qquad \Var(X) = \lambda.

Both computations rely on the Taylor series of the exponential,

ex=∑i=0∞xii!=1+x+x22!+x33!+⋯ ,(4.36)e^{x} = \sum_{i=0}^{\infty} \frac{x^i}{i!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots, \tag{4.36}

and on the cancellation kk!=1(k−1)!\dfrac{k}{k!} = \dfrac{1}{(k-1)!} for k≥1k \ge 1.

Proof of the mean. E[X]=∑k=0∞k⋅e−λλkk!=∑k=1∞k⋅e−λλkk!(the k=0 term is 0)=∑k=1∞e−λλk(k−1)!(cancel k against k!)=λe−λ∑k=1∞λk−1(k−1)!(factor out λe−λ)=λe−λ∑j=0∞λjj!(substitute j=k−1)=λe−λeλ=λ.(Taylor series (4.36))\begin{aligned} \EE[X] &= \sum_{k=0}^{\infty} k \cdot \frac{e^{-\lambda}\lambda^k}{k!} \\ &= \sum_{k=1}^{\infty} k \cdot \frac{e^{-\lambda}\lambda^k}{k!} && \text{(the } k = 0 \text{ term is } 0\text{)} \\ &= \sum_{k=1}^{\infty} \frac{e^{-\lambda}\lambda^k}{(k-1)!} && \text{(cancel } k \text{ against } k!\text{)} \\ &= \lambda e^{-\lambda} \sum_{k=1}^{\infty} \frac{\lambda^{k-1}}{(k-1)!} && \text{(factor out } \lambda e^{-\lambda}\text{)} \\ &= \lambda e^{-\lambda} \sum_{j=0}^{\infty} \frac{\lambda^{j}}{j!} && \text{(substitute } j = k - 1\text{)} \\ &= \lambda e^{-\lambda} e^{\lambda} = \lambda. && \text{(Taylor series (4.36))} \end{aligned}

For the variance, computing E[X2]=∑k2e−λλkk!\EE[X^2] = \sum k^2 \frac{e^{-\lambda}\lambda^k}{k!} directly is awkward because k2k^2 does not cancel cleanly against k!k!. The fix is the factorial moment trick: since X2=X(X−1)+XX^2 = X(X-1) + X, linearity gives

E[X2]=E[X(X−1)]+E[X],(4.37)\EE[X^2] = \EE[X(X-1)] + \EE[X], \tag{4.37}

and k(k−1)k(k-1) cancels against k!k! just as kk did.

Proof of the variance.

Step 1: the factorial moment.

E[X(X−1)]=∑k=0∞k(k−1) e−λλkk!=∑k=2∞k(k−1) e−λλkk!(the k=0,1 terms are 0)=∑k=2∞e−λλk(k−2)!(cancel k(k−1) against k!)=e−λλ2∑k=2∞λk−2(k−2)!(factor out e−λλ2)=e−λλ2eλ=λ2.(same trick: substitute j=k−2)\begin{aligned} \EE[X(X-1)] &= \sum_{k=0}^{\infty} k(k-1)\,\frac{e^{-\lambda}\lambda^k}{k!} \\ &= \sum_{k=2}^{\infty} k(k-1)\,\frac{e^{-\lambda}\lambda^k}{k!} && \text{(the } k = 0, 1 \text{ terms are } 0\text{)} \\ &= \sum_{k=2}^{\infty} \frac{e^{-\lambda}\lambda^k}{(k-2)!} && \text{(cancel } k(k-1) \text{ against } k!\text{)} \\ &= e^{-\lambda}\lambda^2 \sum_{k=2}^{\infty} \frac{\lambda^{k-2}}{(k-2)!} && \text{(factor out } e^{-\lambda}\lambda^2\text{)} \\ &= e^{-\lambda}\lambda^2 e^{\lambda} = \lambda^2. && \text{(same trick: substitute } j = k-2\text{)} \end{aligned}

Step 2: the second moment. By (4.37),

E[X2]=E[X(X−1)]+E[X]=λ2+λ.\EE[X^2] = \EE[X(X-1)] + \EE[X] = \lambda^2 + \lambda.

Step 3: the variance.

Var⁡(X)=E[X2]−(E[X])2=(λ2+λ)−(λ)2=λ.\Var(X) = \EE[X^2] - (\EE[X])^2 = (\lambda^2 + \lambda) - (\lambda)^2 = \lambda.

Mean equals variance (Poisson distribution). The Poisson is the only one of our four distributions whose mean and variance are equal. This is consistent with the Poisson being the limit of Binomial⁡(n,λ/n)\Bin(n, \lambda/n): the binomial variance is n⋅λn(1−λn)=λ(1−λn)→λn \cdot \frac{\lambda}{n}\bigl(1 - \frac{\lambda}{n}\bigr) = \lambda\bigl(1 - \frac{\lambda}{n}\bigr) \to \lambda as n→∞n \to \infty.

The Coupon Collector Problem

Example 4.1 (Coupon collector)

There are NN different coupons you want to collect, found inside cereal boxes. Each box contains exactly one coupon, whose type is uniformly random among the NN types and independent of all other boxes. You buy boxes until you have received all NN distinct coupons. What is the expected number of boxes you must buy?

Let TT be the total time (number of boxes) to collect all NN coupons. Break the process into NN stages. For i=1,…,Ni = 1, \ldots, N, let

Ti=# of boxes bought to obtain the i-th new coupon,T_i = \#\text{ of boxes bought to obtain the } i\text{-th \textit{new} coupon,}

counting from right after the (i−1)(i-1)-th new coupon was obtained. Then the total time is the sum of the stage times,

T=∑i=1NTi.T = \sum_{i=1}^{N} T_i.

Each stage is geometric. During stage ii we already hold i−1i - 1 distinct coupons, so N−(i−1)=N−i+1N - (i-1) = N - i + 1 types would be new. Each box is independently a “success” (a new type) with probability

pi=N−i+1N,soTi∼Geometric⁡ ⁣(N−i+1N).p_i = \frac{N - i + 1}{N}, \qquad\text{so}\qquad T_i \sim \Geom\!\left(\frac{N - i + 1}{N}\right).
  • i=1i = 1: T1∼Geometric⁡(N−1+1N)=Geometric⁡(1)T_1 \sim \Geom\bigl(\frac{N - 1 + 1}{N}\bigr) = \Geom(1), so T1=1T_1 = 1. The first box always gives a new coupon.
  • i=2i = 2: T2∼Geometric⁡(N−2+1N)=Geometric⁡(N−1N)T_2 \sim \Geom\bigl(\frac{N - 2 + 1}{N}\bigr) = \Geom\bigl(\frac{N-1}{N}\bigr).
  • i=Ni = N: TN∼Geometric⁡(1N)T_N \sim \Geom\bigl(\frac{1}{N}\bigr). The last coupon is the hardest to find.

Expected total. Since E[Ti]=1/pi=NN−i+1\EE[T_i] = 1/p_i = \frac{N}{N - i + 1}, linearity of expectation gives

E[T]=E[∑i=1NTi]=∑i=1NE[Ti]=∑i=1NNN−i+1.\EE[T] = \EE\Bigl[\sum_{i=1}^{N} T_i\Bigr] = \sum_{i=1}^{N} \EE[T_i] = \sum_{i=1}^{N} \frac{N}{N - i + 1}.

Write out the terms, from i=1i = 1 (denominator NN) to i=Ni = N (denominator 11):

E[T]=NN+NN−1+NN−2+⋯+N2+N1=N(1N+1N−1+⋯+12+11)=N∑j=1N1j,\begin{aligned} \EE[T] &= \frac{N}{N} + \frac{N}{N-1} + \frac{N}{N-2} + \cdots + \frac{N}{2} + \frac{N}{1} \\ &= N\left(\frac{1}{N} + \frac{1}{N-1} + \cdots + \frac{1}{2} + \frac{1}{1}\right) = N \sum_{j=1}^{N} \frac{1}{j}, \end{aligned}

where we substituted j=N−i+1j = N - i + 1 (as ii runs from 11 to NN, jj runs from NN down to 11). The sum is the NN-th harmonic number HN=∑j=1N1jH_N = \sum_{j=1}^N \frac1j, so

E[T]=N HN.\EE[T] = N\,H_N.
Lemma 4.2 (Size of the harmonic numbers)

For every N≥1N \ge 1,

ln⁡(N+1)≤HN≤1+ln⁡N,\ln(N + 1) \le H_N \le 1 + \ln N,

and more precisely HN=ln⁡N+γ+o(1)H_N = \ln N + \gamma + o(1), where γ≈0.5772\gamma \approx 0.5772 is the Euler–Mascheroni constant.

Proof of the bounds.

Compare each term 1/j1/j with the area under the curve 1/x1/x. Since 1/x1/x is decreasing, on the interval [j,j+1][j, j+1] we have 1/x≤1/j1/x \le 1/j, and on [j−1,j][j-1, j] we have 1/x≥1/j1/x \ge 1/j. Hence

∫jj+1dxx  ≤  1j  ≤  ∫j−1jdxx(j≥2 for the right inequality).\int_j^{j+1}\frac{dx}{x} \;\le\; \frac{1}{j} \;\le\; \int_{j-1}^{j}\frac{dx}{x} \qquad (j \ge 2 \text{ for the right inequality}).

Summing the left inequality over j=1,…,Nj = 1, \ldots, N gives HN≥∫1N+1dxx=ln⁡(N+1)H_N \ge \int_1^{N+1}\frac{dx}{x} = \ln(N+1). Summing the right inequality over j=2,…,Nj = 2, \ldots, N and adding the j=1j=1 term gives HN≤1+∫1Ndxx=1+ln⁡NH_N \le 1 + \int_1^{N}\frac{dx}{x} = 1 + \ln N. (The sharper statement with γ\gamma is a classical result we take as given.)

Corollary 4.3 (Coupon collector asymptotics)
E[T]=N HN≈Nln⁡N+γN≈Nln⁡N.\EE[T] = N\,H_N \approx N \ln N + \gamma N \approx N\ln N.

So we need to buy about a factor of ln⁡N\ln N more boxes than the NN coupons we are trying to collect.

Numbers and intuition. For N=50N = 50, H50≈4.499H_{50} \approx 4.499, so E[T]≈225\EE[T] \approx 225 boxes, about 4.5×4.5\times the number of coupon types. Most of the cost comes at the end: the final coupon alone takes E[TN]=N\EE[T_N] = N boxes on average, while the entire first half of the collection takes fewer than NN boxes in total (∑i≤N/2NN−i+1≤N2⋅2=N\sum_{i \le N/2} \frac{N}{N-i+1} \le \frac{N}{2}\cdot 2 = N). This Nln⁡NN\ln N behavior shows up whenever we need to “hit every bin” by random sampling: hashing, load balancing, and covering every node in a network.

The Memoryless Property

Theorem 4.7 (Memoryless property of the geometric)

Let X∼Geometric⁡(p)X \sim \Geom(p) with 0<p<10 < p < 1. For all integers s,t≥0s, t \ge 0,

P(X>s+t∣X>s)=P(X>t).\PP(X > s + t \mid X > s) = \PP(X > t).

In words: given that we have already failed ss times, the probability of failing tt more times is the same as if we were starting over from scratch.

Proof.

First note that P(X>s)=(1−p)s>0\PP(X > s) = (1-p)^s > 0, so the conditional probability is well defined. By the definition of conditional probability,

P(X>s+t∣X>s)=P({X>s+t}∩{X>s})P(X>s).\PP(X > s + t \mid X > s) = \frac{\PP\bigl(\{X > s + t\} \cap \{X > s\}\bigr)}{\PP(X > s)}.

Since s+t≥ss + t \ge s, the event {X>s+t}\{X > s + t\} is contained in {X>s}\{X > s\} (if we have s+ts+t failures, we certainly have ss failures), so the intersection is just {X>s+t}\{X > s + t\}:

P(X>s+t∣X>s)=P(X>s+t)P(X>s).\PP(X > s + t \mid X > s) = \frac{\PP(X > s + t)}{\PP(X > s)}.

Both numerator and denominator are values of the geometric survival function (4.27):

P(X>s+t)P(X>s)=(1−p)s+t(1−p)s=(1−p)t,\frac{\PP(X > s + t)}{\PP(X > s)} = \frac{(1-p)^{s+t}}{(1-p)^{s}} = (1-p)^{t},

which is exactly the survival function of the geometric evaluated at tt, i.e. P(X>t)\PP(X > t).

Two remarks on memorylessness.

  1. The remaining wait is again geometric. Given X>sX > s, the number of additional trials X−sX - s has the same distribution as XX: for k≥1k \ge 1, P(X−s=k∣X>s)=P(X=s+k)P(X>s)=(1−p)s+k−1 p(1−p)s=(1−p)k−1 p.\PP(X - s = k \mid X > s) = \frac{\PP(X = s + k)}{\PP(X > s)} = \frac{(1-p)^{s+k-1}\,p}{(1-p)^{s}} = (1-p)^{k-1}\,p. This is the form we use in the derivations below.
  2. Uniqueness. The geometric is the only memoryless distribution on {1,2,3,…}\{1, 2, 3, \ldots\}. Its continuous analog, the exponential distribution, will be the only memoryless continuous distribution.

To use memorylessness to recompute E[X]\EE[X], we need to split an expectation according to which of several events occurred. This is the expectation version of the law of total probability from Lecture 2.

Theorem 4.8 (Total expectation theorem)

Let A1,…,AnA_1, \ldots, A_n be a partition of Ω\Omega with P(Ai)>0\PP(A_i) > 0 for each ii, and define the conditional expectation given an event, E[X∣Ai]=∑xx P(X=x∣Ai)\EE[X \mid A_i] = \sum_x x\,\PP(X = x \mid A_i). Then

E[X]=∑i=1nP(Ai) E[X∣Ai].\EE[X] = \sum_{i=1}^{n} \PP(A_i)\,\EE[X \mid A_i].
Proof.

For each value xx, the law of total probability gives P(X=x)=∑iP(Ai) P(X=x∣Ai)\PP(X = x) = \sum_i \PP(A_i)\,\PP(X = x \mid A_i). Substituting into the definition of expectation and swapping the order of summation (justified by absolute convergence),

E[X]=∑xx P(X=x)=∑xx∑iP(Ai) P(X=x∣Ai)=∑iP(Ai)∑xx P(X=x∣Ai)=∑iP(Ai) E[X∣Ai].\begin{aligned} \EE[X] &= \sum_x x\,\PP(X = x) = \sum_x x \sum_i \PP(A_i)\,\PP(X = x \mid A_i) \\ &= \sum_i \PP(A_i) \sum_x x\,\PP(X = x \mid A_i) = \sum_i \PP(A_i)\,\EE[X \mid A_i]. \end{aligned}
Example 4.2 (Geometric mean via memorylessness)

Let X∼Geometric⁡(p)X \sim \Geom(p). Condition on the outcome of the first trial, using the partition {X=1}\{X = 1\} (first trial succeeds) and {X>1}\{X > 1\} (first trial fails):

E[X]=P(X=1) E[X∣X=1]+P(X>1) E[X∣X>1].\EE[X] = \PP(X = 1)\,\EE[X \mid X = 1] + \PP(X > 1)\,\EE[X \mid X > 1].
  • P(X=1)=p\PP(X = 1) = p (success on the first try), and then X=1X = 1 exactly, so E[X∣X=1]=1\EE[X \mid X = 1] = 1.
  • P(X>1)=1−p\PP(X > 1) = 1 - p. If the first trial failed, the geometric “tells us we start again”: by memorylessness the remaining wait X−1X - 1 is again Geometric⁡(p)\Geom(p), and we have already spent one trial. So E[X∣X>1]=E[(X−1)+1∣X>1]=E[X]+1.\EE[X \mid X > 1] = \EE[(X - 1) + 1 \mid X > 1] = \EE[X] + 1.

Substituting,

E[X]=p⋅1+(1−p)(E[X]+1)=p+E[X]+1−p E[X]−p=E[X]+1−p E[X].\begin{aligned} \EE[X] &= p \cdot 1 + (1-p)\bigl(\EE[X] + 1\bigr) \\ &= p + \EE[X] + 1 - p\,\EE[X] - p \\ &= \EE[X] + 1 - p\,\EE[X]. \end{aligned}

Subtracting E[X]\EE[X] from both sides gives 0=1−p E[X]0 = 1 - p\,\EE[X], i.e. p E[X]=1p\,\EE[X] = 1, so

E[X]=1p,\EE[X] = \frac{1}{p},

matching the tail sum computation.

Two checks on this argument.

  1. Finiteness. Subtracting E[X]\EE[X] from both sides is only legitimate because E[X]<∞\EE[X] < \infty, which we already know from the tail sum. (If E[X]=∞\EE[X] = \infty, the equation ∞=∞+1−∞\infty = \infty + 1 - \infty says nothing.)
  2. Sanity check the answer. Any correct formula must satisfy E[X]≥1\EE[X] \ge 1 (you need at least one trial) and E[X]→∞\EE[X] \to \infty as p→0p \to 0. A sign slip in the algebra can produce E[X]=11+p\EE[X] = \frac{1}{1+p}, which fails both tests, since it is less than 11 for every p>0p > 0.
Theorem 4.9 (Geometric variance (supplementary))

If X∼Geometric⁡(p)X \sim \Geom(p), then

Var⁡(X)=1−pp2.\Var(X) = \frac{1 - p}{p^2}.
Proof.

We use the same first-trial conditioning, now on E[X2]\EE[X^2] (which is finite, since the tail of XX decays geometrically).

E[X2]=P(X=1) E[X2∣X=1]+P(X>1) E[X2∣X>1].\EE[X^2] = \PP(X = 1)\,\EE[X^2 \mid X = 1] + \PP(X > 1)\,\EE[X^2 \mid X > 1].
  • Given X=1X = 1: X2=1X^2 = 1, so E[X2∣X=1]=1\EE[X^2 \mid X = 1] = 1.
  • Given X>1X > 1: by memorylessness, X=1+X′X = 1 + X' where X′∼Geometric⁡(p)X' \sim \Geom(p) has the same distribution as XX. Expanding the square, E[X2∣X>1]=E[(1+X′)2]=1+2 E[X′]+E[X′2]=1+2 E[X]+E[X2].\EE[X^2 \mid X > 1] = \EE\bigl[(1 + X')^2\bigr] = 1 + 2\,\EE[X'] + \EE[X'^2] = 1 + 2\,\EE[X] + \EE[X^2].

Substituting, with E[X]=1/p\EE[X] = 1/p:

E[X2]=p⋅1+(1−p)(1+2 E[X]+E[X2])=p+(1−p)+2(1−p) E[X]+(1−p) E[X2]=1+2(1−p)p+(1−p) E[X2].\begin{aligned} \EE[X^2] &= p \cdot 1 + (1-p)\bigl(1 + 2\,\EE[X] + \EE[X^2]\bigr) \\ &= p + (1 - p) + 2(1-p)\,\EE[X] + (1-p)\,\EE[X^2] \\ &= 1 + \frac{2(1-p)}{p} + (1-p)\,\EE[X^2]. \end{aligned}

Move the E[X2]\EE[X^2] terms to the left:

E[X2]−(1−p) E[X2]=p E[X2]=1+2(1−p)p=p+2−2pp=2−pp.\EE[X^2] - (1-p)\,\EE[X^2] = p\,\EE[X^2] = 1 + \frac{2(1-p)}{p} = \frac{p + 2 - 2p}{p} = \frac{2 - p}{p}.

Dividing by pp, E[X2]=2−pp2\EE[X^2] = \dfrac{2 - p}{p^2}. Finally,

Var⁡(X)=E[X2]−(E[X])2=2−pp2−1p2=1−pp2.\Var(X) = \EE[X^2] - (\EE[X])^2 = \frac{2 - p}{p^2} - \frac{1}{p^2} = \frac{1 - p}{p^2}.

Cross-check with the factorial moment trick. Differentiating ∑k≥0xk=11−x\sum_{k\ge0}x^k = \frac{1}{1-x} twice gives ∑k≥2k(k−1)xk−2=2(1−x)3\sum_{k\ge2} k(k-1)x^{k-2} = \frac{2}{(1-x)^3}. With x=1−px = 1-p,

E[X(X−1)]=∑k=2∞k(k−1)(1−p)k−1p=p(1−p)∑k=2∞k(k−1)(1−p)k−2=p(1−p)⋅2p3=2(1−p)p2,\EE[X(X-1)] = \sum_{k=2}^{\infty} k(k-1)(1-p)^{k-1}p = p(1-p)\sum_{k=2}^{\infty} k(k-1)(1-p)^{k-2} = p(1-p)\cdot\frac{2}{p^3} = \frac{2(1-p)}{p^2},

so E[X2]=E[X(X−1)]+E[X]=2(1−p)p2+pp2=2−pp2\EE[X^2] = \EE[X(X-1)] + \EE[X] = \frac{2(1-p)}{p^2} + \frac{p}{p^2} = \frac{2 - p}{p^2}, in agreement.

Poisson Merging and Splitting

Poisson random variables model counts of arrivals (packets at a router, calls at a switchboard, customers at a queue). Two structural facts make them especially convenient: independent Poisson counts merge into a Poisson count, and randomly splitting a Poisson count produces independent Poisson counts.

Theorem 4.10 (Poisson merging (sum of independent Poissons))

Let X∼Poisson⁡(λ)X \sim \Pois(\lambda) and Y∼Poisson⁡(μ)Y \sim \Pois(\mu) be independent. Then

X+Y∼Poisson⁡(λ+μ),X + Y \sim \Pois(\lambda + \mu),

with mean E[X+Y]=λ+μ\EE[X + Y] = \lambda + \mu.

Proof (supplementary).

Fix n∈{0,1,2,…}n \in \{0, 1, 2, \ldots\}. Since X,Y≥0X, Y \ge 0, the event {X+Y=n}\{X + Y = n\} splits into the disjoint events {X=k,Y=n−k}\{X = k, Y = n - k\} for k=0,…,nk = 0, \ldots, n:

P(X+Y=n)=∑k=0nP(X=k, Y=n−k)=∑k=0nP(X=k) P(Y=n−k)(independence)=∑k=0ne−λλkk!⋅e−μμn−k(n−k)!(Poisson PMFs)=e−(λ+μ)∑k=0nλkμn−kk! (n−k)!(collect exponentials)=e−(λ+μ)n!∑k=0nn!k! (n−k)! λkμn−k(multiply and divide by n!)=e−(λ+μ)n!∑k=0n(nk)λkμn−k=e−(λ+μ) (λ+μ)nn!.(binomial theorem)\begin{aligned} \PP(X + Y = n) &= \sum_{k=0}^{n} \PP(X = k,\, Y = n - k) \\ &= \sum_{k=0}^{n} \PP(X = k)\,\PP(Y = n - k) && \text{(independence)} \\ &= \sum_{k=0}^{n} \frac{e^{-\lambda}\lambda^k}{k!} \cdot \frac{e^{-\mu}\mu^{n-k}}{(n-k)!} && \text{(Poisson PMFs)} \\ &= e^{-(\lambda+\mu)} \sum_{k=0}^{n} \frac{\lambda^k \mu^{n-k}}{k!\,(n-k)!} && \text{(collect exponentials)} \\ &= \frac{e^{-(\lambda+\mu)}}{n!} \sum_{k=0}^{n} \frac{n!}{k!\,(n-k)!}\,\lambda^k \mu^{n-k} && \text{(multiply and divide by } n!\text{)} \\ &= \frac{e^{-(\lambda+\mu)}}{n!} \sum_{k=0}^{n} \binom{n}{k}\lambda^k \mu^{n-k} \\ &= \frac{e^{-(\lambda+\mu)}\,(\lambda+\mu)^n}{n!}. && \text{(binomial theorem)} \end{aligned}

This is exactly the Poisson⁡(λ+μ)\Pois(\lambda+\mu) PMF evaluated at nn. The mean λ+μ\lambda + \mu also follows directly from linearity of expectation.

Corollary 4.4 (Many independent Poissons)

If X1,…,XmX_1, \ldots, X_m are independent with Xi∼Poisson⁡(λi)X_i \sim \Pois(\lambda_i), then ∑i=1mXi∼Poisson⁡(∑i=1mλi)\sum_{i=1}^m X_i \sim \Pois\bigl(\sum_{i=1}^m \lambda_i\bigr). (Apply the theorem repeatedly; X1+⋯+XkX_1 + \cdots + X_{k} is independent of Xk+1X_{k+1}.)

Networking picture: merging. Two independent packet streams feed a router through separate buffers. If the numbers of packets arriving in each buffer during an interval are Poisson⁡(λ)\Pois(\lambda) and Poisson⁡(μ)\Pois(\mu), the number of packets in the merged output buffer is Poisson⁡(λ+μ)\Pois(\lambda + \mu).

Two buffers, Poisson(λ) and Poisson(μ), feed a router whose output buffer is Poisson(λ + μ)

Splitting is the reverse operation: each arriving packet is routed to one of two outputs by an independent coin flip. Given the total count X=nX = n, the number YY sent to the first output is the number of successes in nn independent Bernoulli(p)(p) trials. This is a “binomial with a random number of trials.”

Theorem 4.11 (Poisson splitting)

Let X∼Poisson⁡(λ)X \sim \Pois(\lambda), and suppose that, conditioned on X=nX = n, the random variable YY satisfies

Y∣X=n  ∼  Binomial⁡(n,p).Y \mid X = n \;\sim\; \Bin(n, p).

Let Z=X−YZ = X - Y be the remainder. Then

Y∼Poisson⁡(λp),Z∼Poisson⁡(λ(1−p)),andY⊥Z.Y \sim \Pois(\lambda p), \qquad Z \sim \Pois\bigl(\lambda(1-p)\bigr), \qquad\text{and}\qquad Y \perp Z.
Proof (supplementary).

We compute the joint PMF of (Y,Z)(Y, Z) and show that it factors. Fix integers a,b≥0a, b \ge 0. The event {Y=a,Z=b}\{Y = a, Z = b\} is the same as {X=a+b, Y=a}\{X = a + b,\, Y = a\} (the total is a+ba + b, of which aa went to the first output). By the chain rule,

P(Y=a, Z=b)=P(X=a+b) P(Y=a∣X=a+b)=e−λλa+b(a+b)!⋅(a+ba)pa(1−p)b(Poisson, then binomial)=e−λλa+b(a+b)!⋅(a+b)!a! b! pa(1−p)b(expand the binomial coefficient)=e−λ λapaa!⋅λb(1−p)bb!(cancel (a+b)!, split λa+b)=e−λp(λp)aa!⏟Poisson⁡(λp) PMF at a⋅e−λ(1−p)(λ(1−p))bb!⏟Poisson⁡(λ(1−p)) PMF at b,(split e−λ=e−λpe−λ(1−p))\begin{aligned} \PP(Y = a,\, Z = b) &= \PP(X = a + b)\,\PP(Y = a \mid X = a + b) \\ &= \frac{e^{-\lambda}\lambda^{a+b}}{(a+b)!} \cdot \binom{a+b}{a} p^a (1-p)^b && \text{(Poisson, then binomial)} \\ &= \frac{e^{-\lambda}\lambda^{a+b}}{(a+b)!} \cdot \frac{(a+b)!}{a!\,b!}\, p^a (1-p)^b && \text{(expand the binomial coefficient)} \\ &= e^{-\lambda}\,\frac{\lambda^{a}p^a}{a!}\cdot\frac{\lambda^{b}(1-p)^b}{b!} && \text{(cancel } (a+b)!\text{, split } \lambda^{a+b}\text{)} \\ &= \underbrace{\frac{e^{-\lambda p}(\lambda p)^a}{a!}}_{\Pois(\lambda p)\text{ PMF at } a} \cdot \underbrace{\frac{e^{-\lambda(1-p)}(\lambda(1-p))^b}{b!}}_{\Pois(\lambda(1-p))\text{ PMF at } b}, && \text{(split } e^{-\lambda} = e^{-\lambda p}e^{-\lambda(1-p)}\text{)} \end{aligned}

Marginal of YY. Sum over b≥0b \ge 0. The second factor is a PMF in bb, so it sums to 11, leaving P(Y=a)=e−λp(λp)aa!\PP(Y = a) = \frac{e^{-\lambda p}(\lambda p)^a}{a!}. Thus Y∼Poisson⁡(λp)Y \sim \Pois(\lambda p). Summing over aa instead shows Z∼Poisson⁡(λ(1−p))Z \sim \Pois(\lambda(1-p)).

Independence. The joint PMF equals the product of the two marginals for every (a,b)(a, b), which is the definition of Y⊥ZY \perp Z.

Why the independence is surprising. If the total XX were a fixed number nn, then YY and Z=n−YZ = n - Y would be perfectly (negatively) dependent: learning YY would tell you ZZ exactly. It is the randomness of the total count that makes the two outputs independent. A large value of YY suggests XX was large, which exactly offsets what it would otherwise say about ZZ. This is special to the Poisson.

A Poisson(λ) buffer splits with probability p into Y ~ Poisson(λp) and with probability 1 − p into Z ~ Poisson(λ(1 − p))

Conditional PMFs and Conditional Expectation

Definition 4.4 (Conditional PMF)

Let X,YX, Y be discrete random variables and let yy satisfy pY(y)>0p_Y(y) > 0. The conditional PMF of XX given Y=yY = y is

pX∣Y(x∣y)≜P(X=x∣Y=y)=pX,Y(x,y)pY(y).p_{X\mid Y}(x \mid y) \triangleq \PP(X = x \mid Y = y) = \frac{p_{X,Y}(x, y)}{p_Y(y)}.

It is a genuine PMF in xx. For each fixed yy with pY(y)>0p_Y(y) > 0:

  • pX∣Y(x∣y)≥0p_{X\mid Y}(x \mid y) \ge 0, since it is a ratio of a probability and a positive number;
  • it sums to one over xx, by marginalizing the joint PMF: ∑xpX∣Y(x∣y)=1pY(y)∑xpX,Y(x,y)=pY(y)pY(y)=1.\sum_x p_{X\mid Y}(x \mid y) = \frac{1}{p_Y(y)}\sum_x p_{X,Y}(x, y) = \frac{p_Y(y)}{p_Y(y)} = 1.

So for each fixed value yy, “XX given Y=yY = y” is just another random variable with its own distribution, and we can take its expectation. (Note that the fraction is pX,Y(x,y)/pY(y)p_{X,Y}(x,y)/p_Y(y), a ratio of PMF values, rather than P(X∩Y)/P(Y)\PP(X \cap Y)/\PP(Y), since XX and YY are random variables rather than events.)

Definition 4.5 (Conditional expectation given Y=yY = y)

For yy with pY(y)>0p_Y(y) > 0, the conditional expectation of XX given Y=yY = y is

E[X∣Y=y]≜∑xx⋅pX∣Y(x∣y)=∑xx⋅P(X=x∣Y=y).(4.74)\EE[X \mid Y = y] \triangleq \sum_{x} x \cdot p_{X\mid Y}(x \mid y) = \sum_x x \cdot \PP(X = x \mid Y = y). \tag{4.74}

Like any expectation, E[X∣Y=y]\EE[X \mid Y = y] is just a real number.

By “sweeping” through the values of yy in (4.74), we get a (possibly different) number E[X∣Y=y]\EE[X \mid Y = y] for every value yy. That is, y↦E[X∣Y=y]y \mapsto \EE[X \mid Y = y] is a function of yy.

Definition 4.6 (Conditional expectation as a random variable)

Define g(y)=E[X∣Y=y]g(y) = \EE[X \mid Y = y]. The conditional expectation of XX given YY is the random variable

E[X∣Y]≜g(Y).\EE[X \mid Y] \triangleq g(Y).

It is a function of YY, and therefore E[X∣Y]\EE[X \mid Y] is itself a random variable: it takes the value g(y)g(y) with probability pY(y)p_Y(y).

Notation: E[X∣Y=y]\EE[X \mid Y = y] versus E[X∣Y]\EE[X \mid Y]. These are different objects. E[X∣Y=y]\EE[X \mid Y = y] (lowercase yy, a specific value) is a number. E[X∣Y]\EE[X \mid Y] (capital YY) is a random variable.

Example 4.3 (Die roll, conditioned on parity)

Roll a fair six-sided die. Let XX be the result and Y=1{X is even}Y = \mathbf{1}\{X \text{ is even}\}.

Given Y=1Y = 1, XX is uniform on {2,4,6}\{2, 4, 6\}, so E[X∣Y=1]=2+4+63=4\EE[X \mid Y = 1] = \frac{2 + 4 + 6}{3} = 4. Given Y=0Y = 0, XX is uniform on {1,3,5}\{1, 3, 5\}, so E[X∣Y=0]=1+3+53=3\EE[X \mid Y = 0] = \frac{1 + 3 + 5}{3} = 3. Hence

E[X∣Y]=g(Y)={4if Y=1,3if Y=0,i.e.E[X∣Y]=3+Y.\EE[X \mid Y] = g(Y) = \begin{cases} 4 & \text{if } Y = 1, \\ 3 & \text{if } Y = 0, \end{cases} \qquad\text{i.e.}\qquad \EE[X \mid Y] = 3 + Y.

This is a random variable taking the values 33 and 44, each with probability 12\tfrac12. Notice that its mean is 12(3)+12(4)=3.5=E[X]\tfrac12(3) + \tfrac12(4) = 3.5 = \EE[X]. That is no coincidence, as the next lecture will show.

Law of Iterated Expectation (Tower Rule): TBD next lecture. This was on today’s agenda but was not reached in lecture. It states that E[E[X∣Y]]=E[X]\EE\bigl[\EE[X \mid Y]\bigr] = \EE[X]; the total expectation theorem of Section 4.5 is a special case.

Summary: Common Discrete Distributions

DistributionPMF P(X=k)\PP(X = k)SupportE[X]\EE[X]Var⁡(X)\Var(X)
Bernoulli⁡(p)\Bern(p)pk(1−p)1−kp^k(1-p)^{1-k}{0,1}\{0, 1\}ppp(1−p)p(1-p)
Binomial⁡(n,p)\Bin(n, p)(nk)pk(1−p)n−k\binom{n}{k}p^k(1-p)^{n-k}{0,…,n}\{0, \ldots, n\}npnpnp(1−p)np(1-p)
Geometric⁡(p)\Geom(p)(1−p)k−1p(1-p)^{k-1}p{1,2,…}\{1, 2, \ldots\}1p\dfrac{1}{p}1−pp2\dfrac{1-p}{p^2}
Poisson⁡(λ)\Pois(\lambda)e−λλkk!\dfrac{e^{-\lambda}\lambda^k}{k!}{0,1,2,…}\{0, 1, 2, \ldots\}λ\lambdaλ\lambda

5389 words