Var and cov of difference of pmf I was trying to compute the variance and covariance of some distribution, I'll explain the details below. I found something, but I was wondering if there was not an easier method... thanks !
Suppose $N$ has pmf : $P[N=n]=(1/4)(3/4)^{n-1}$ 
Suppose $X|N=n$ has distribution $P[X=k|N=n]= {n \choose k}\frac{1}{2^n}$  (for $k=0,\dots,n$)
The joint pmf of X and N is $ P[X=k,N=n]={ n \choose k} \frac{3}{8^n} $ for $n \geq 1 \mbox{ and } k=0,\dots,n$ 
I was trying to compute $Var[N-X]$ by computing $E[N-X]$ and $E[(N-X)^2]$ as follow :
$E[N-X]=\sum_{n \geq 1} \sum_{k=0}^n  \frac{3}{8^n} (n-k) {n \choose k} = \frac{2}{3}$ 
$E[(N-X)^2]=\sum_{n \geq 1} \sum_{k=0}^n  \frac{3}{8^n} (n-k)^2 {n \choose k}   = \frac{8}{9}$
$Var[N-X]=\frac{8}{9}-\frac{4}{9}=\frac{4}{9}$
I skipped the details, but the computation of the previous sum are not so easy and I used the function $ f(x)=\frac{1}{1-x}=\sum_{n \geq 0} x^n $ and $ g(x)= \sum_{k=0}^n {n \choose k} x^n $ and their derivative to find them.
Is there an easier way?
Similarly to compute $Cov[N-X,X]=Cov[N,X]-Cov[X,X]$ I computed :
$ E[X]=\sum_{n \geq 1} \sum_{k=0}^n k {n \choose k}\frac{3}{8^n} = \frac{2}{3}$ 
$ E[X^2]=\sum_{n \geq 1} \sum_{k=0}^n k^2 {n \choose k}\frac{3}{8^n} = \frac{8}{9}$ 
$ E[N] = E[X]+\frac{2}{3}=\frac{4}{3}$ 
$ E[NX]= \sum_{n \geq 1} \sum_{k=0}^n nk {n \choose k}\frac{3}{8^n} = \frac{10}{9}$
$Cov[X,N]=\frac{10}{9}-\frac{4}{3}\frac{2}{3}=\frac{2}{9}$ 
$Cov[X,X]=Var(X)=E[X^2]-E[X]^2=\frac{4}{9}$ 
$Cov[N-X,X]=-\frac{2}{9}$ 
Again, I had to use the previous function ... same question, isn't there an easier method ? Maybe we can use the low of total expectation/variance or the fact that $N$ is a geometric distribution or $X|N$ is a binomial distribution to derive it more quickly ...
Thanks !
 A: 
Again, I had to use the previous function ... same question, isn't there an easier method ? Maybe we can use the low of total expectation/variance or the fact that $N$ is a geometric distribution or $X|N$ is a binomial distribution to derive it more quickly ...

I am not sure about "more quickly" in this age of online computational knowledge engines, but indeed we may use the distribution's known properties to do it without (anything) performing integrations/summations.
The Variance of $N-X$ can more quickly be determined by observing that if $X$ is the count of successes in $N$ events with success rate $1/2$, then $N-X$ is the count of failures in $N$ events with failure rate $1/2$.
Therefore $X$ and $N-X$ have identical distributions.
The Law of Total Variance may then be employed.
$$\begin{align}\mathsf {Var}(N-X) & =\mathsf {Var}(X)\\ & = \mathsf {Var}(\mathsf E(X\mid N))+\mathsf E(\mathsf {Var}(X\mid N))\end{align}$$
Which can be evaluated using your knowledge of the relevant distributions (and the Linearity of Expectation).

However, since $N-X$ and $X$ are clearly dependent, we cannot just use the identicallity of distribution to evaluate the covariance (as indeed is the point).   However, we may use the Bilinearity of Covariance, and the distributions' properties, after using the Law of Total Covariance.
$$\begin{align}\mathsf {Cov}(N-X,X) & = \mathsf {Cov}(N,X)-\mathsf {Var}(X)\\&= \mathsf E(\mathsf {Cov}(N,X\mid N))+\mathsf {Cov}(\mathsf E(N\mid N),\mathsf E(X\mid N))-\mathsf{Var}(X)\\&= \mathsf E(\mathsf E(NX\mid N)-\mathsf E(N\mid N)\mathsf E(X\mid N))+\mathsf {Cov}(N,\mathsf E(X\mid N) -\mathsf{Var}(X)\\&= \mathsf {Cov}(N,\mathsf E(X\mid N)) -\mathsf{Var}(X)\end{align}$$
Notice: the variance of $X$ is available from the prior calculations, so you just need to evaluate the other term.
