# Conditional Expectation of random sum of independent random variables

Let $Y=X_1+X_2+\dots+X_N$ where $X_1,X_2,\dots,N$ are jointly independent random variables, $X_1,X_2 ...$ identically distributed continuous random variables with finite expectation, and $N$ a discrete random variable with finite expectation.

What is the definition of conditional density $f(y|n)$ of $Y$ given $N=n$ (if it exists). I need it to compute $E(Y|N=n)$.

Is there another approach to compute $E(Y|N=n)$ or even $E(Y|N)$?

For simplicity we can assume that the random variable $N$ is bounded by a positive integer M

• No, there is no reason $N$ needs to be bounded; e.g. it could be Poisson or negative binomial. All that is needed is that we can look at $Y$ conditioned on a fixed non-random value of $N$, and then sum over all those values by the probabilities of the possible values of $N$. – user452 Aug 28 '13 at 2:32
• "I need it to compute E(Y|N=n)" No, the latter is simpler than the former. But the conditional density of $Y$ conditionally on $N=n$ is simply the $n$th convolution power $f\ast f\ast\cdots\ast f$ of the common density $f$ of the $X_k$. – Did Aug 28 '13 at 18:14
• Thanks yes I get that - please see my reply at the bottom. I was working within the context of most text books. I am having a hard time trying to understand conditioning when Xi are continuous using the simple definition of conditional density as a ratio. Maybe I should try and define Conditional distribution of Y given N =n, as the joint probability of [Y<=y,N=n] will be well defined, and try and go in that direction. I can see though how your method will work, if we are willing to accept that E(YIn) exists and the linearity of Expectations of sums of non discrete/continuous random variables. – dyuta Aug 28 '13 at 19:06
• What textbook are you working with? Why do you think that, for some finite natural number $n$, that $f(y|n)$ doesn't exist? For a fixed $n$, $P(Y<y|N=n)=P(X_1+X_2+...+X_n<y)$. How does this not exist? What seems to be bothering you is that $Y$ is a mixture of continuous and discrete random variables, and you can't say if the CDF is continuous. Well in general, it might not be continuous, but the CDF is right continuous, and that's just fine! – user452 Aug 28 '13 at 22:57
• trb456 thanks. Yes we could define Conditional distribution of Y given N=n, and integrate against the conditional distribution. In the text books I have seen - when discussing joint and conditional distributions associated with(X,Y) either both rvs were discrete or both continuous. Next Expectation and Conditional expectation were defined only with respect to pdf/pmf as the variables had densities. Its clear that in this problem we need to go beyond these simple definitions. Thanks for your help. – dyuta Aug 29 '13 at 2:18

In actuarial science, this is the basic form of a collective risk model. There is a discrete distribution from which an annual loss frequency is drawn, and each of those losses has a severity drawn from some continuous distribution. The sum total of those losses is the expected aggregate loss the insurer/reinsurer/homeowner/etc. expects.

Somewhat more formally, if $N$ is a discrete random variable, and $X$ is a continuous random variable, we can define $S$ as the aggregate loss random variable where $S = X_1 + X_2 + \ldots + X_N, X \in {0, 1, 2, \ldots}$.

Given some basic independence assumptions, simply the $X's$ (jointly or singly) do not depend on $N$ and vice versa, it can be shown that: $$E(S) = E(N)E(X)\\ Var(S) = E(N)Var(X) + Var(N)E(X)^2$$ The proof is based on convolution of the probability generating functions. See (Klugman et al. 1998, pp.295–298).

As soakley showed below, the first expectation is relatively simple to derive. The second can be understood knowing the law of total variance which is: $$Var(X) = E_Y[Var(X|Y)] + Var_Y[E(X|Y)]$$ or, in English, the total variance is the expected value of the conditional variance plus the variance of the conditional expected value. See (Heckman & Meyer 1989, p.30) for this derivation.

## Adding derivation of Variance (edit)

Given the law of total probability, we can say that $Var(S) = E[Var(S|N)] + Var[E(S|N)]$. Now, $S|N$ is merely $X_1 + X_2 + \ldots + X_N$, and we are given the value of $n$. So let's rewrite. $$Var(S) = E[Var(X_1 + X_2 + \ldots + X_N)] + Var[E(X_1 + X_2 + \ldots + X_N)]$$ One of our assumptions in compound variance, which you also mentioned in your question, is that the X's are iid. Therefore, in the first term, $Var(X_1 + X_2 + \ldots + X_N)$ collapses to $N\cdot Var(X)$. Similarly, the second term $E(X_1 + X_2 + \ldots + X_N)$ simply becomes $N*E(X)$, so we now have: $$Var(S) = E[N\cdot Var(X)] + Var(N\cdot E(X)]$$ To complete the conditioning, we need to take the expectations and variances over $N$. But the $X$'s are constants with respect to $N$, so we get: $$Var(S) = E[N]Var(X) + Var(N)E[X]^2$$ since the $E(X)$ component in the variance comes outside squared and the $Var(X)$ component in the expectation comes out directly, which demonstrates the second relationship.

Heckman, Philip E., and Glenn G. Meyers. "The calculation of aggregate loss distributions from claim severity and claim count distributions." Proceedings of the Casualty Actuarial Society. Vol. 70. 1983.

Klugman, S. A.; Panjer, H. H. & Willmot, G. E. Loss models: from data to decisions John Wiley & Sons, Inc., 1998

• Thanks Avraham - I think you forgot to add the reference. I was looking for the proof though. – dyuta Aug 27 '13 at 23:01
• Avraham - I had a quick look. Pretty non standard approach using Loss Algorithms. I was hoping somebody might tell me how to specify the conditional density f(y|n) of Y given N=n, else suggest another way to solve E(Y). To provide a formal proof does one have to use Wald's Equation? – dyuta Aug 27 '13 at 23:52
• @dyuta I've added the derivation of the variance assuming the law of total probability. Hope that helps. – Avraham Aug 28 '13 at 1:52

Recall that the definition of conditional probability is:

$P(A|B) = \frac{P(A \cap B)}{P(B)}$, and so $P(A|B)P(B) = P(A \cap B)$

For your problem, the second form is applicable:

$P(Y|N=n)P(N=n) = P(Y \cap N=n)$

You now take expectations across the probability distributions. The key insights are:

1) When you consider $E(Y|N=n)$, you have temporarily fixed the value of $N$, so you treat it as the non-random value $n$. Then as soakley notes, $E(Y|N=n)=nE(X_1)$ by the definition of $Y$ and that the $X_i$'s are iid. You "unfix" $N$ by then taking the expectation of $N$ across all its possible values

2) Since the $X_i$'s and $N$ are independent you can use the product rule from the conditional probability definition. Taking expectations over all possible $N$'s, you convert

$E(Y|N=n)=E(X_1)n$ to $E(Y|N)E(N)=E(X_1)E(N)$, which is Avraham's answer. Avraham's answer is quite thorough, by the way, and the references are worth checking.

In general, $f(y|n)$ might not have a closed form, so if all you want is the expectation (and variance), you are better off simply computing those quantities directly, as the answers here have shown.

EDIT: Let's try this: $E(Y)=E_N(E_X(Y|N=n))$

This iterated expectation formula is valid by definition. It says that first we condition $N=n$, and then look at the inner expectation on $Y$, which is now a fixed sum of $n$ iid random variables, each with expectation $E(X_1)$. Now we take a second expectation across $N$, the outer expectation. So the total expectation is the product of the expectation of $N$ and the expectation of $X_1$, given that these are independent.

• thanks trb456 for editing the question. But unfortunately I am possibly looking for a more 'formal' proof. Your expressions P(Y|N=n) as well as P(Y intersect N = n) are not clear to me. You usually see expressions P[Y lies in set A|N=n] and P[Y lies in A, N=n] as Y is a continuous rv, and where A is a Borel set, such as an interval. I understand the intuition behind all the answers, but there are a few gaps in the proof. For example what result/theorem justifies E[Y|N=n]= E[X1+X2+...Xn], given that E[Y|N=n] is the expectation of Y with respect to the conditional distribution of Y given N=n. – dyuta Aug 28 '13 at 2:17
• The result that justifies $E[Y|N=n]= E[X_1+X_2+...X_n]$, given that $E[Y|N=n]$ is the expectation of $Y$ with respect to the conditional distribution of $Y$ given $N=n$, is that $N$ is no longer a random variable given its conditioning, and so we can simply sum up the expectation of $n$ independent random variables. If this is still not clear, then I'm afraid you do not really understand what is going on at a fairly fundamental level, and so no answer short of a lesson in conditional probability is going to help you. Sorry to be so blunt, but there it is. – user452 Aug 28 '13 at 2:28
• Lets say your answer while intuitively clear to me, does not appear to me to be justified by given set of theorems/definitions etc. I will of course refresh my understanding of Conditional Expectation. Thanks for your help though. – dyuta Aug 28 '13 at 3:02
• "Lets say your answer ... does not appear to me to be justified by given set of theorems/definitions etc." Sorry? All this is arch-canonical. – Did Aug 29 '13 at 19:46

The expected value is relatively easy for this case as long as the expectation for $X_i$ exists. Since $N$ is known, you are looking to find $$E[Y|N=n] = E[X_1+X_2+ \cdots + X_N|N=n]= E[X_1 + X_2+ \cdots + X_n].$$ Since expectation is a linear operator, you can write this as $$E[Y|N=n] = E[X_1]+E[X_2]+ \cdots + E[X_n].$$ From there we have $$E[Y|N=n]=nE[X_1]$$

• Thanks Soakley. But what 'result' - definition/theorem did you use to justify the claim E[Y|N=n]=E[X1+X2+...+Xn]. I do of course recognize the intuition behind the claim. – dyuta Aug 27 '13 at 22:58
• I've added in an intermediate step in the first line to show the progression. I would say this is done by the definition of a conditional expectation. A more loose version might call it by "substitution" since $N$ is known. That is, as trb456 noted, $N$ is no longer a random variable, but has a known realization of $n.$ If $N$ is known, you can substitute in its value. – soakley Aug 28 '13 at 18:08
• @dyuta Note that $Y\mathbf 1_{N=n}=(X_1+\cdots+X_n)\mathbf 1_{N=n}$ hence $E[Y\mid N=n]=E[X_1+\cdots+X_n|N=n]$, and that the random variables $X_1+\cdots+X_n$ and $N$ are independent hence $E[X_1+\cdots+X_n|N=n]=E[X_1+\cdots+X_n]$. – Did Aug 28 '13 at 18:11
• Did-In text books, E(X) is defined only in the case of density or pmf. Similarly if (X,Y) are jointly continuous rv, we define the conditional density as the appropriate ratio, after which we define E(Y|X=x) as the appropriate integral. Here N is discrete and Y is not if X is continuous and N indep of X. So E(Y|N=n) is tricky. If X were discrete I can see how the conditioning conditioning arguments go through. Here what you have are M vars Yj=X1+...+Xj, and Y is in terms of Yj, j=1,...M, as you have described. Using linearity of E, we are OK if E(YIn) is OK, as YIn is not disc/cont. – dyuta Aug 28 '13 at 18:48
• Seems like an excellent motivation to throw away said textbooks and go for more reliable sources. – Did Aug 29 '13 at 19:45