St · Statistics & Probability

How Do You Sum a Random Number of Independent Variables?

Updated 13 October 2026

At a glance

  1. 1. Define the random sum

    Let N be a nonnegative integer-valued count and add the first N terms of a sequence.

  2. 2. Check independence

    For the standard formulas, N must be independent of the mutually independent, identically distributed summands.

  3. 3. Condition on the count

    Given N, use the usual formulas for a fixed number of summands.

  4. 4. Apply total expectation and variance

    Average the conditional mean and combine the average conditional variance with the variance of the conditional mean.

A random sum has a random number of terms as well as random terms. A standard example is the total reward from a random number of events. To calculate its mean and variance, you need to account for both sources of randomness.

The formulas below assume the count is independent of the summands, and that the summands are mutually independent and identically distributed (iid). If those assumptions do not hold, the result can change.

The random-sum formulas

Let NN be a nonnegative integer-valued random variable, and let X1,X2,…X_1, X_2, \ldots be iid random variables independent of NN. Define

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

with S0=0S_0=0. Write μ=E[Xi]\mu=\mathbb{E}[X_i] and σ2=Var⁡(Xi)\sigma^2=\operatorname{Var}(X_i). If the relevant expectations and variances are finite, then

E[SN]=E[N]μ\mathbb{E}[S_N]=\mathbb{E}[N]\mu

and

Var⁡(SN)=E[N]σ2+Var⁡(N)μ2.\operatorname{Var}(S_N)=\mathbb{E}[N]\sigma^2+\operatorname{Var}(N)\mu^2.

The first formula says that the expected total is the expected number of terms multiplied by the expected value of each term. The variance has two parts: variation in the individual terms, E[N]σ2\mathbb{E}[N]\sigma^2, and variation in how many terms are included, Var⁡(N)μ2\operatorname{Var}(N)\mu^2.

Why the formulas work

Condition on the value of NN. If N=nN=n, the sum contains a fixed number nn of independent terms, so

E[SN∣N=n]=nμ,Var⁡(SN∣N=n)=nσ2.\mathbb{E}[S_N\mid N=n]=n\mu, \qquad \operatorname{Var}(S_N\mid N=n)=n\sigma^2.

Taking the expectation of the conditional mean gives the mean of the random sum:

E[SN]=E[E[SN∣N]]=E[Nμ]=μE[N].\mathbb{E}[S_N] =\mathbb{E}\big[\mathbb{E}[S_N\mid N]\big] =\mathbb{E}[N\mu] =\mu\mathbb{E}[N].

For the variance, use the law of total variance:

Var⁡(SN)=E[Var⁡(SN∣N)]+Var⁡(E[SN∣N])=E[Nσ2]+Var⁡(Nμ)=σ2E[N]+μ2Var⁡(N).\begin{aligned} \operatorname{Var}(S_N) &=\mathbb{E}[\operatorname{Var}(S_N\mid N)] +\operatorname{Var}(\mathbb{E}[S_N\mid N])\\ &=\mathbb{E}[N\sigma^2]+\operatorname{Var}(N\mu)\\ &=\sigma^2\mathbb{E}[N]+\mu^2\operatorname{Var}(N). \end{aligned}

This argument is often the quickest way to solve a random-sum problem: find the conditional mean and variance for a fixed count, then apply the two laws of total expectation and variance.

Worked example

Suppose a number of events NN has a Poisson distribution with mean 33. Each event independently contributes either 11 or 33 units, with equal probability. Let XiX_i be the contribution from event ii.

For one event,

μ=E[Xi]=1+32=2,σ2=(1−2)2+(3−2)22=1.\mu=\mathbb{E}[X_i]=\frac{1+3}{2}=2, \qquad \sigma^2=\frac{(1-2)^2+(3-2)^2}{2}=1.

For a Poisson random variable with parameter 33, both E[N]\mathbb{E}[N] and Var⁡(N)\operatorname{Var}(N) equal 33. Therefore,

E[SN]=3⋅2=6\mathbb{E}[S_N]=3\cdot 2=6

and

Var⁡(SN)=3⋅1+3⋅22=15.\operatorname{Var}(S_N)=3\cdot 1+3\cdot 2^2=15.

So the expected total contribution is 66 units, and its variance is 1515 units squared. The standard deviation is 15\sqrt{15}, about 3.873.87 units.

For a Poisson count with mean λ\lambda, the same formulas give E[SN]=λμ\mathbb{E}[S_N]=\lambda\mu and Var⁡(SN)=λ(σ2+μ2)\operatorname{Var}(S_N)=\lambda(\sigma^2+\mu^2). The latter can also be written λE[Xi2]\lambda\mathbb{E}[X_i^2].

Finding the distribution

If you need the full distribution rather than just its mean and variance, condition on NN. For any measurable set AA,

Pr⁡(SN∈A)=∑n=0∞Pr⁡(N=n)Pr⁡(X1+⋯+Xn∈A),\Pr(S_N\in A)=\sum_{n=0}^{\infty}\Pr(N=n)\Pr(X_1+\cdots+X_n\in A),

where the sum of zero terms is defined to be 00.

For moment-generating functions, when they exist, let MX(t)=E[etXi]M_X(t)=\mathbb{E}[e^{tX_i}] and let GN(z)=E[zN]G_N(z)=\mathbb{E}[z^N] be the probability-generating function of NN. Independence gives

MSN(t)=GN(MX(t)).M_{S_N}(t)=G_N(M_X(t)).

This composition is useful when the individual summand and the count have known distributions.

Common mistakes and variations

  • Leaving out the count’s variability. The variance is not generally just E[N]σ2\mathbb{E}[N]\sigma^2. The additional term Var⁡(N)μ2\operatorname{Var}(N)\mu^2 is needed unless the count is fixed, or the summands have mean zero.
  • Assuming independence without checking it. The formulas require NN to be independent of the sequence of summands. If the number of terms is chosen based on their values, conditioning can change the distribution of the included terms.
  • Assuming identical distributions. If the independent summands have different means μi\mu_i but are independent of NN, the expectation instead takes the form E[SN]=∑i≥1Pr⁡(N≥i)μi\mathbb{E}[S_N]=\sum_{i\geq 1}\Pr(N\geq i)\mu_i, provided expectation and summation can be interchanged (for example, if ∑i≥1Pr⁡(N≥i)E[∣Xi∣]<∞\sum_{i\geq 1}\Pr(N\geq i)\mathbb{E}[|X_i|]<\infty). The simple product E[N]μ\mathbb{E}[N]\mu uses a common mean.

For example, if XiX_i are fair Bernoulli variables and NN is the index of the first success, then SN=1S_N=1 with certainty. Here NN depends on the summands, so the independent-count variance formula does not apply. Always check how the count is generated before using the random-sum formulas.

References

  1. Introduction to Probability Models, Sheldon M. Ross

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.