Unit 7, lesson 51

Random Sums with Independent Counts

How to find the mean and variance of a random sum, a total whose number of terms is a random count, by conditioning on a count independent of the IID terms, and why the empty sum equals zero.

  • Video 51
  • Conditional Expectation and Total Variance

A work session on a server contains a random number of jobs, and each job adds a random delay. The total delay is then a sum whose number of terms is itself random. Can its mean and variance be found from the mean and variance of one delay and of the number of jobs? This lesson shows that they can when the delays are IID and the count is independent of them, by conditioning on the count and applying the law of total variance, and it settles what a sum with no terms means.

Key terms

Random count

Definition A random count is a random variable NN whose possible values are nonnegative integers 0,1,2,…0, 1, 2, \dots. In a random sum it is the number of terms that are added. The results on this page assume that the count is independent of the whole sequence of terms X1,X2,…X_1, X_2, \dots, which means that NN is independent of the vector (X1,…,Xk)(X_1, \dots, X_k) for every kk. Independence of NN from each term separately is weaker, and it is not enough for the variance formula below.

In plain words The number of terms carries no information about the values of the terms. Learning the value of NN tells you how many terms there are and changes nothing about the distribution of their values. A count that never looks at the terms can still fail this, for example when busy periods bring both more jobs and longer delays.

Example In a constructed service model, a coin toss independent of all delays decides whether a session has N=1N = 1 or N=3N = 3 jobs, each with probability 12\frac12. Then E[N]=2E[N] = 2, E[N2]=1+92=5E[N^2] = \frac{1 + 9}{2} = 5 and Var⁡(N)=5−4=1\operatorname{Var}(N) = 5 - 4 = 1. The number of requests that reach a server in a minute, modeled as Pois⁡(λ)\operatorname{Pois}(\lambda), is another common random count.

Random sum

Definition Let X1,X2,…X_1, X_2, \dots be IID random variables and let NN be a random count independent of the whole sequence. The random sum is

S=∑i=1NXi,S = \sum_{i=1}^{N} X_i ,

so on an outcome where N=nN = n the value of SS is X1+⋯+XnX_1 + \dots + X_n, the partial sum SnS_n of the first nn terms. For each nn with P(N=n)>0P(N = n) > 0, independence makes the conditional distribution of (X1,…,Xn)(X_1, \dots, X_n) given N=nN = n equal to its unconditional distribution. Given N=nN = n, the random sum is therefore an ordinary sum of nn IID terms.

In plain words Two sources of randomness feed the total, how many terms there are and how large each term is. The sequence of possible terms is part of the model whether or not a term is used, and NN only decides how many of them are counted. Conditioning on NN removes the first source and leaves a sum with a fixed number of terms.

Example Let each delay XiX_i be 00 or 44 minutes with probability 12\frac12 each, independently, and let NN be the count of the previous card. One delay has mean μ=2\mu = 2 minutes, second moment E[Xi2]=8E[X_i^2] = 8 square minutes and variance σ2=8−4=4\sigma^2 = 8 - 4 = 4 square minutes. On an outcome with N=3N = 3 and delays 4,0,4,0,…4, 0, 4, 0, \dots, the total is S=4+0+4=8S = 4 + 0 + 4 = 8 minutes, and the fourth delay is not counted. Given N=1N = 1 the total is one delay, 00 or 44 with probability 12\frac12 each. Given N=3N = 3 the number of delays equal to 44 minutes is Bin⁡(3,12)\operatorname{Bin}(3, \frac12), so the total is 00, 44, 88 or 1212 with conditional probabilities 18\frac18, 38\frac38, 38\frac38 and 18\frac18.

Empty sum

Definition A sum with no terms, such as ∑i=10Xi\sum_{i=1}^{0} X_i, is defined to be 00. So S=0S = 0 on the event {N=0}\{N = 0\}. This convention keeps the rule Sn+1=Sn+Xn+1S_{n+1} = S_n + X_{n+1} for the partial sums true at n=0n = 0, and it makes the conditional formulas E[S∣N=n]=nμE[S \mid N = n] = n\mu and Var⁡(S∣N=n)=nσ2\operatorname{Var}(S \mid N = n) = n\sigma^2 of the next cards hold at n=0n = 0 as well.

In plain words A session with no jobs adds no delay, so its total is zero rather than undefined. The converse can fail. A nonempty sum can also be zero, for example when every included term is 00, so P(S=0)P(S = 0) is at least P(N=0)P(N = 0) and can be larger.

Example Let NN be 00, 11 or 22 with probabilities 14\frac14, 12\frac12 and 14\frac14, independent of delays that are 00 or 44 minutes as before. The total is 00 on the empty session, on a one-job session whose delay is 00, and on a two-job session whose delays are both 00, so

P(S=0)=14⋅1+12⋅12+14⋅14=916.\begin{aligned} P(S = 0) &= \tfrac14 \cdot 1 + \tfrac12 \cdot \tfrac12 \\[0.4em] &\quad + \tfrac14 \cdot \tfrac14 = \tfrac{9}{16} . \end{aligned}

This is more than P(N=0)=14P(N = 0) = \frac14. Without the convention, SS would have no value on an event of probability 14\frac14.

Mean of a random sum

Definition Let X1,X2,…X_1, X_2, \dots be identically distributed with finite mean μ\mu, and let NN be a random count with E[N]<∞E[N] < \infty that is independent of the whole sequence. Then

E[S]=E[N] μ.E[S] = E[N]\,\mu .

For each nn with P(N=n)>0P(N = n) > 0, independence and linearity give E[S∣N=n]=E[X1]+⋯+E[Xn]=nμE[S \mid N = n] = E[X_1] + \dots + E[X_n] = n\mu, and the empty sum gives the same at n=0n = 0. So E[S∣N]=NμE[S \mid N] = N\mu, and the tower rule gives E[S]=E[Nμ]=E[N] μE[S] = E[N\mu] = E[N]\,\mu. The same argument applied to the nonnegative terms ∣Xi∣\lvert X_i \rvert shows that E[∣S∣]≤E[N] E[∣X1∣]<∞E[\lvert S \rvert] \le E[N]\, E[\lvert X_1 \rvert] < \infty, so SS has a finite mean and the tower rule applies. This formula does not need the terms to be independent of each other, and the terms may take negative values.

In plain words The expected total is the expected number of terms times the mean of one term. The shortcut works because the count carries no information about the terms. If the count is chosen by looking at the terms, conditioning on NN can change their distribution, and the formula needs a separate argument and can fail, as the last question below shows.

Example In the service model, E[S∣N=1]=2E[S \mid N = 1] = 2 and E[S∣N=3]=6E[S \mid N = 3] = 6 minutes, so

E[S]=12⋅2+12⋅6=4E[S] = \tfrac12 \cdot 2 + \tfrac12 \cdot 6 = 4

minutes. The formula gives the same value, E[N] μ=2⋅2=4E[N]\,\mu = 2 \cdot 2 = 4 minutes.

Variance of a random sum

Definition Let X1,X2,…X_1, X_2, \dots be IID with mean μ\mu and finite variance σ2\sigma^2, and let NN be a random count with E[N2]<∞E[N^2] < \infty that is independent of the whole sequence. Then

Var⁡(S)=E[N] σ2+Var⁡(N) μ2.\begin{aligned} \operatorname{Var}(S) &= E[N]\,\sigma^2 \\[0.4em] &\quad + \operatorname{Var}(N)\,\mu^2 . \end{aligned}

For each nn with P(N=n)>0P(N = n) > 0, the terms X1,…,XnX_1, \dots, X_n are still IID given N=nN = n, so their variances add and Var⁡(S∣N=n)=nσ2\operatorname{Var}(S \mid N = n) = n\sigma^2. Together with E[S∣N=n]=nμE[S \mid N = n] = n\mu this gives E[S2]=E[N] σ2+E[N2] μ2<∞E[S^2] = E[N]\,\sigma^2 + E[N^2]\,\mu^2 < \infty. The law of total variance with NN as the group label then gives the within-group variation E[Nσ2]=E[N] σ2E[N\sigma^2] = E[N]\,\sigma^2 and the between-group variation Var⁡(Nμ)=μ2Var⁡(N)\operatorname{Var}(N\mu) = \mu^2 \operatorname{Var}(N). The step Var⁡(S∣N=n)=nσ2\operatorname{Var}(S \mid N = n) = n\sigma^2 uses the independence of the terms from each other as well as from NN.

In plain words Two kinds of uncertainty add up. Even when the count is known, the terms vary, and that gives E[N] σ2E[N]\,\sigma^2. The count itself varies, which moves the conditional mean NμN\mu up and down, and that gives Var⁡(N) μ2\operatorname{Var}(N)\,\mu^2. Replacing NN by its mean, when that mean is a whole number, keeps the mean of the total right but drops the second part. The second part uses μ2\mu^2, so a negative mean, such as an average loss, adds as much to it as a positive mean of the same size, and the second part vanishes when μ=0\mu = 0.

Example In the service model, Var⁡(S∣N)=4N\operatorname{Var}(S \mid N) = 4N and E[S∣N]=2NE[S \mid N] = 2N, so the within part is 4E[N]=84E[N] = 8, the between part is Var⁡(2N)=4Var⁡(N)=4\operatorname{Var}(2N) = 4\operatorname{Var}(N) = 4, and Var⁡(S)=12\operatorname{Var}(S) = 12 square minutes. A fixed count of 2=E[N]2 = E[N] jobs would give only 2⋅4=82 \cdot 4 = 8. To check the formula, multiply the conditional probabilities of each branch of the count by its weight 12\frac12 and add the branches that give the same total. The total 00 gets 14\frac14 from the one-job branch and 116\frac{1}{16} from the three-job branch, and the total 44 gets 14\frac14 and 316\frac{3}{16}.

ss0044881212
P(S=s)P(S = s)516\frac{5}{16}716\frac{7}{16}316\frac{3}{16}116\frac{1}{16}

The four probabilities add to 11. From the table, E[S]=28+24+1216=4E[S] = \frac{28 + 24 + 12}{16} = 4 and E[S2]=112+192+14416=28E[S^2] = \frac{112 + 192 + 144}{16} = 28, so Var⁡(S)=28−16=12\operatorname{Var}(S) = 28 - 16 = 12 square minutes. If instead every job in a session shared the same delay, with Xi=X1X_i = X_1 for all ii and NN still independent of X1X_1, the total would be NX1N X_1. Its mean would still be 44, but its variance would be E[N2] E[X12]−16=5⋅8−16=24E[N^2]\,E[X_1^2] - 16 = 5 \cdot 8 - 16 = 24 instead of 1212, because the terms are no longer independent of each other.

Check yourself

  1. Let NN be 00 or 22 with probability 12\frac12 each, independent of IID delays that are 00 or 44 minutes with probability 12\frac12 each. Find E[S]E[S], Var⁡(S)\operatorname{Var}(S) and P(S=0)P(S = 0).
Show the answer

The count has E[N]=1E[N] = 1, E[N2]=2E[N^2] = 2 and Var⁡(N)=2−1=1\operatorname{Var}(N) = 2 - 1 = 1, and one delay has μ=2\mu = 2 and σ2=4\sigma^2 = 4. So E[S]=1⋅2=2E[S] = 1 \cdot 2 = 2 minutes and Var⁡(S)=1⋅4+1⋅22=8\operatorname{Var}(S) = 1 \cdot 4 + 1 \cdot 2^2 = 8 square minutes.

The total is 00 for certain on the empty session, which has probability 12\frac12. On a two-job session both delays are 00 with probability 14\frac14, which contributes 12⋅14=18\frac12 \cdot \frac14 = \frac18. So P(S=0)=12+18=58P(S = 0) = \frac12 + \frac18 = \frac58.

  1. The number of requests NN that reach a server in one minute is Pois⁡(3)\operatorname{Pois}(3). Each request has size 11 or 33 units with probability 12\frac12 each, the sizes are IID, and they are independent of NN. Find the mean and variance of the total size SS, and the probability that S=0S = 0.
Show the answer

One request has μ=2\mu = 2, E[Xi2]=1+92=5E[X_i^2] = \frac{1 + 9}{2} = 5 and σ2=5−4=1\sigma^2 = 5 - 4 = 1. A Poisson count has E[N]=Var⁡(N)=3E[N] = \operatorname{Var}(N) = 3. So E[S]=3⋅2=6E[S] = 3 \cdot 2 = 6 units and Var⁡(S)=3⋅1+3⋅4=15\operatorname{Var}(S) = 3 \cdot 1 + 3 \cdot 4 = 15 square units. With a Pois⁡(λ)\operatorname{Pois}(\lambda) count the formula reduces to λE[Xi2]\lambda E[X_i^2], and here 3⋅5=153 \cdot 5 = 15 gives the same answer.

Every request has size at least 11, so the total is 00 only on the empty sum, and P(S=0)=P(N=0)=e−3≈0.0498P(S = 0) = P(N = 0) = e^{-3} \approx 0.0498.

  1. Delays X1,X2,…X_1, X_2, \dots are IID, 00 or 44 minutes with probability 12\frac12 each. A rule looks at the first delay and sets N=1N = 1 if X1=4X_1 = 4 and N=0N = 0 if X1=0X_1 = 0. Find E[S]E[S] and Var⁡(S)\operatorname{Var}(S), compare them with the formulas for random sums, and say which assumption fails.
Show the answer

If X1=4X_1 = 4, the sum is X1=4X_1 = 4. If X1=0X_1 = 0, the sum is empty and equals 0=X10 = X_1. So S=X1S = X_1 in every case, with E[S]=2E[S] = 2 minutes and Var⁡(S)=4\operatorname{Var}(S) = 4 square minutes.

The count has E[N]=12E[N] = \frac12 and Var⁡(N)=14\operatorname{Var}(N) = \frac14, so the formulas would give E[N] μ=1E[N]\,\mu = 1 and E[N] σ2+Var⁡(N) μ2=2+1=3E[N]\,\sigma^2 + \operatorname{Var}(N)\,\mu^2 = 2 + 1 = 3. Both are wrong. The count is not independent of the delays, since it is computed from X1X_1. Given N=1N = 1 the included delay is 44 for certain, so E[S∣N=1]=4E[S \mid N = 1] = 4 instead of 1⋅μ=21 \cdot \mu = 2, and conditioning on NN has changed the distribution of the term.

How this lesson connects