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{equation} \begin{split} cov(X,Y)&=cov(\sum^Na_k,\sum^{N'}a_k)\\ &=cov(\sum\mathbb{1}_{k<N}a_k,\sum\mathbb{1}_{k<N'}a_k)\\ &=cov(\sum\mathbb{1}_{k<N}a_k,\sum\mathbb{1}_{k<N'}a_k)\\ &=\sum\sum cov(\mathbb{1}_{k<N}a_k,\mathbb{1}_{k'<N'}a_{k'})\\ &=\sum\sum \mathbb{1}_{k<N\cap k'<N'}cov(a_k,a_{k'})\\ &=\sum \mathbb{1}_{k<\min(N,N')}var (a_k)\\ &=\min(N,N')var(a) \end{split} \end{equation}
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