# Covariance of random sums

How can I compute $$cov(\sum^N a_k,\sum^{N'}a_k)$$ where $$N$$, $$N'$$ are random dependent variables and $$a_k$$ iid random variables , as a function of (but not necessarily) cov(N,N'), $$var(N)$$, $$var(N')$$, $$var(a_k)$$ and all of their expectation value ?

$$N$$ and $$N'$$ are bounded and positive.

My best shot :

$$$$\begin{split} cov(X,Y)&=cov(\sum^Na_k,\sum^{N'}a_k)\\ &=cov(\sum\mathbb{1}_{k

Feels wrong, is the 4th step right ? I use bilinearity on infinite sums, moreover if $$N$$ and $$N'$$ were constants the same method would have worked so...

Thank you

• So the number of summands is random? In any case, you might want to take advantage of the fact (or better yet, prove to yourself) that the covariance is a bilinear map. Nov 6, 2021 at 17:19
• the number of summand is random, yes. Because that is the case, I do not believe I can use bilinearity straightforwardly as is usually done @Galen Nov 6, 2021 at 17:33
• N and N' are finite and strictly positive, it's $\sum^n_i\sum^{n'}_j a_i b_j$ Nov 6, 2021 at 17:43
• Yes they are independent Nov 6, 2021 at 18:03
• Your idea looks sound, but you made a mistake with the fifth equal sign: when you take the indicator functions out of the covariance, the result is suddenly random (since $N$ and $N'$ are random). This cannot be right, since the left-hand side is not random. Nov 7, 2021 at 10:53

Law of total covariance (wiki) helps here. What you found is when $$N$$ and $$N'$$ are given:
$$\operatorname{cov}(X,Y|N,N')=\operatorname{var}(a)\min(N,N')$$
$$\mathbb E[X|N,N']=N\mathbb E[a], \ \ E[Y|N,N']=N'\mathbb E[a]$$
Plugging in gives us: $$\operatorname{cov}(X,Y)=\operatorname{var}(a)\mathbb E[\min(N,N')]+\mathbb E[a]^2\operatorname{cov}(N,N')$$