# Compute $\mathrm{Cov}(\sum_{i=1}^NX_i,\sum_{i=1}^NY_i)$

Let $X_1,X_2,\dots$ be i.i.d. Bernoulli random variables with parameter $\frac{1}{4}$. Let $Y_1,Y_2, \dots$ be another sequence of i.i.d. Bernoulli random variables with parameter $\frac{3}{4}$. And let $N$ be a geometric random variable with parameter $\frac{1}{2}$ (i.e., $\mathrm{P}(N = k) =\frac{1}{2^k},\, \forall\ k=1,2,\dots$). Assume the $X_i$’s, $Y_j$ ’s and $N$ are all independent. Compute $$\mathrm{Cov}(\sum_{i=1}^NX_i,\sum_{i=1}^NY_i).$$

Here $N$ is also an r.v. so I think I need to use conditional covariance. How can I solve this?

Where to start? I am stuck in the first step?

-
Hint: are you familiar with the Law of Total Covariance? The independence of the $X_i$ from the $Y_i$ causes the formula to simplify, so that all you really need to know that isn't entirely trivial is the expectation of $N$. –  whuber Aug 8 '12 at 22:10

$Cov(\sum_{i=1}^NX_i,\sum_{i=1}^NY_i)=E(\sum_{i=1}^NX_i \sum_{i=1}^NY_i)-E(\sum_{i=1}^NX_i)E(\sum_{i=1}^NY_i)$

Define $S_N^X=\sum_{i=1}^NX_i$

Note that $E(S_N^X)=E(E(S_N^X|N))$

Now $E(S_N^X|N=n)=E(S_n^X|N=n)=E(\sum_{i=1}^nX_i|N=n)=E(\sum_{i=1}^nX_i)$[Due to independence of $N$ and $X_i$'s ]$=nE(X_1)$

So, $E(S_N^X)=E(N.E(X_1))=E(N)E(X_1)=2.\frac{1}{4}=\frac{1}{2}$ Similarly $E(S_N^Y)=\frac{3}{2}$

Again $E(\sum_{i=1}^NX_i \sum_{i=1}^NY_i)=E(S_N^XS_N^Y)=E(E(S_N^XS_N^Y)|N)$

Here $E(E(S_N^XS_N^Y)|N=n)=E(nX_1.nY_1)=n^2E(X_1)E(Y_1)$[Due to independence of $X_i$'s and $Y_i$'s]

So,$E(\sum_{i=1}^NX_i \sum_{i=1}^NY_i)=E(N^2E(X_1)E(Y_1))=6.\frac{1}{4}\frac{3}{4}=\frac{9}{8}$

So,$Cov(\sum_{i=1}^NX_i,\sum_{i=1}^NY_i)=\frac{9}{8}-\frac{1}{2}\frac{3}{2}=\frac{3}{8}$

-
I saw Wald's Equation and from that fact I try to solve my problem. –  Argha Aug 9 '12 at 10:53
Your answer involves $n$, which seems to be a realization of $N$. Does that seem reasonable? –  MånsT Aug 9 '12 at 10:53
@MånsT: To Find the conditional probability First I consider N=n(fixed).But lastly I consider it as variable.In this way We proof Wald's Equation also. –  Argha Aug 9 '12 at 10:57
The crucial step is realizing that $E(S_N^X)=E(N)E(X_1)$. But $E(X_1)=E(X_i)\neq n/2$. Get rid of that $n$ and you've solved the problem. –  MånsT Aug 9 '12 at 11:34
@MånsT: You are right .X~Ber(1/4) not X~Bin(n, 1/4) Thank you. –  Argha Aug 9 '12 at 11:37

Cov(∑X$_i$, ∑Y$_i$)=E(∑X$_i$ ∑Y$_i$)-E(∑X$_i$)E(∑Y$_i$) where the sum is taken up to the random integer N. To calculate this you do need to take the expectation with respect to the geometric distribution for N of the conditional expectation given N=n. Now conditioned on N=n ∑X$_i$ is binomial n, 1/4 and ∑Y$_i$ is binomial n, 3/4 So E(∑X$_i$|N=n)=E(∑Y$_i$|N=n)=3n/16. Now you need to compute E(∑X$_i$ ∑Y$_i$|N=n).

Suppose f(n) denotes the conditional covariance given N=n. Then to get the unconditional covariance you would compute the following sum:

∑f(n)/2$^n$ where the sum runs from n=1 to ∞.

-
The independence assumptions (stated in the question) imply that conditional on $N$, the covariance of $\sum_{i=1}^n X_i$ and $\sum_{i=1}^n Y_i$ must be zero, whence $f(n)$ is identically $0$. Your last formula would then imply the unconditional covariance is also $0$, but that's obviously not correct. –  whuber Aug 8 '12 at 20:17
@whuber When I read the question initially it only said that the Xis were iid Bernoulli sequence p=1/4 and the Yi were anotheriid Bernoulli sequence p=3/4. I did not see except in the current edited version that all of Xi Yi and n were independent of each other. But if the Xis and Yis are independent how is it that they would be dependent conditional on N=n? –  Michael Chernick Aug 8 '12 at 20:42
You can check the edit record to verify that the independence assumption was present all along, so it is unnecessary (and pointless) to argue about that. For intuition, consider simulating some pairs of $(\sum X_i, \sum Y_j)$. The first coordinate will tend to equal $n/4$ (with some scatter) while the second will tend to equal $3n/4$ (with equal scatter). Whence a scatterplot should follow the line $y=3x$, implying positive correlation, whence nonzero covariance. I can make such a scatterplot of $10^7$ such points in $4$ seconds: their covariance is very close to $3/8$. –  whuber Aug 8 '12 at 21:05
Michael, @whuber has given an exploratory approach to discovering this; here is some intuition. The sums are mixtures of binomials. Consider a clustering-like scenario: A mixture of two bivariate normals, each with $\rho = 0$ (hence having independent coordinates). Suppose the mean of each coordinate is zero in the first mixture component and is 10 in the second mixture component. If I tell you that $X = 9$, then you certainly wouldn't claim that this tells you nothing about the value of $Y$. Right? –  cardinal Aug 8 '12 at 22:13
(I have undeleted this post in order to make the comment thread available to readers.) –  whuber Dec 5 '12 at 17:13