Compute the probability mass function of $X -Y$ I'd be very thankful if someone help me guide how to solve the following problem.
Let $X$ and $Y$ be independent and geometrically distributed with the same parameter $p$. 
1) Compute the probability mass function of $X - Y$.
2) Can you also compute $P(X=Y)$ now?
Hi, this is how i tried for 1) but not sure whether it is correct. Since $X$ and $Y$ are geometric distributed we have
$$
P(X=x) = (1-p)^x p,
$$
where $x\geq 0$. Let $Z=X-Y$. Then
$$
\begin{align}
P(Z=z) &= \sum_{x=1}^z P(X=x,Y=y) \\
&= \sum_{x=1}^z P(X=x , Y=x-z) \\
&= \sum_{x=1}^z P(X=x) P(Y=x-z) \\
&= \sum_{x=1}^z (1-p)^x p (1-p)^{x-z} p \\
&= \sum_{x=1}^z p^2 (1-p)^{2x-z} \\
&= (z+1) p^2 (1-p)^{2x-z}
\end{align}
$$
2) $P(X=Y) = P(X-Y=1) = P(Z=1)$. So, will substitute $z=1$ in 1).
 A: You're working in the correct mindset, but there are a few issues to iron out. The event $\{Z = z\}$ is certainly the union of events of the type $\{X=x, Y=x-z\}$. However, since $X$ and $Y$ are geometric, the values they are allowed to take are non-negative integers, so $X=x$ makes sense when $x = 0, 1, 2, ..$ but $Y=x-z$ only makes sense for $x = z, z+1, z+2,... $ Let's consider two cases:
Case 1: $z \geq 0$. The union you're looking for is
$$
\{Z=z\} = \bigcup_{x=z}^{\infty} \{X=x,Y=x-z\}
$$
The events in the union are disjoint, this translates to
$$
P(Z=z) = \sum_{x=z}^{\infty} P(X=x,Y=x-z)
$$
and by independence of $X$ and $Y$ (as you used above!)
$$
\sum_{x=z}^{\infty} P(X=x,Y=x-z) = \sum_{x=z}^{\infty}P(X=x)P(Y=x-z).
$$
Finally, to finish off
$$
\sum_{x=z}^{\infty} P(X=x)P(Y=x-z)=\sum_{x=z}^{\infty} p(1-p)^x p(1-p)^{x-z} = p^2 \sum_{x=z}^{\infty} (1-p)^{2x-z} \\
= p^2(1-p)^z\sum_{x=z}^{\infty}(1-p)^{2(x-z)} = p^2 (1-p)^z \sum_{x=0}^{\infty} (1-p)^{2x} \\
= p^2 (1-p)^z \frac{1}{1-(1-p)^2} = \frac{p(1-p)^z}{2-p}
$$
Notice that the manipulations I did were so that I could apply the geometric series formula. So we arrive at $P(Z=z) = \frac{p(1-p)^z}{2-p}$ when $z \geq 0$.
Case 2: $z < 0$. The union you're looking for this time is
$$
\{Z=z\} = \bigcup_{x=0}^{\infty} \{X=x,Y=x-z\}.
$$
In a similar fashion to the previous case, you will end up with
$$
P(Z=z) = p^2 \sum_{x=0}^{\infty}(1-p)^{2x-z} = p^2(1-p)^{-z}\sum_{x=0}^{\infty}(1-p)^{2x} \\
= p^2 (1-p)^{-z}\frac{1}{1-(1-p)^2} = \frac{p(1-p)^{-z}}{2-p}
$$
So, when $z < 0$ you find $P(Z=z) = \frac{p(1-p)^{-z}}{2-p}$.
If you wanted to compile this into a nice expression for all $z$, you can notice that the only difference when $z$ was negative compared to positive is that in the negative case you have $-z$, but when $z$ is negative $-z = |z|$. So, for any $z$
$$
P(Z=z) = \frac{p(1-p)^{|z|}}{2-p}.
$$
For your second question, you have the right idea, but $P(X=Y) = P(X-Y=0)=P(Z=0)$ and since you now have the probability mass function for $Z$, you can just evaluate at $z=0$.
A: $\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$
Lets $\ds{z \equiv x - y}$. Since $\ds{x\ \geq\ 0}$ and $\ds{y\ \geq\ 0}$, we'll have $\ds{-\infty\ <\ z\ <\ +\infty}$:

\begin{align}&\color{#66f}{\large\left.%
\sum_{x\ =\ 0}^{\infty}\pars{1 - p}^{x}p\sum_{y\ =\ 0}^{\infty}\pars{1 - p}^{y}p
\right\vert_{\, z\ =\ x\ -\ y}}
=p^{2}\left.%
\sum_{x\ =\ 0}^{\infty}\sum_{y\ =\ 0}^{\infty}\pars{1 - p}^{x + y}
\right\vert_{\, z\ =\ x\ -\ y}
\end{align}

Then,

\begin{align}&\color{#66f}{\large\left.%
\sum_{x\ =\ 0}^{\infty}\pars{1 - p}^{x}p\sum_{y\ =\ 0}^{\infty}\pars{1 - p}^{y}p
\right\vert_{\, z\ =\ x\ - y}}
=p^{2}\left.%
\sum_{x\ =\ 0}^{\infty}\pars{1 - p}^{x + \pars{x - z}}\sum_{y\ =\ 0}^{\infty}1
\right\vert_{\, y\ =\ x\ -\ z}
\\[5mm]&=p^{2}\pars{1 - p}^{-z}\left.%
\sum_{x\ =\ 0}^{\infty}\pars{1 - p}^{2x}\right\vert_{\, x\ \geq\ z}
=p^{2}\pars{1 - p}^{-z}
\left\lbrace\begin{array}{lcrcl}
\sum_{x\ =\ 0}^{\infty}\pars{1 - p}^{2x} & \mbox{if} & z & \leq & 0 
\\[2mm]
\sum_{x\ =\ z}^{\infty}\pars{1 - p}^{2x} & \mbox{if} & z & > & 0 
\end{array}\right.
\\[5mm]&=p^{2}\pars{1 - p}^{-z}
\left\lbrace\begin{array}{lcrcl}
{1 \over 1 - \pars{1 - p}^{2}} & \mbox{if} & z & \leq & 0 
\\[2mm]
{\pars{1 - p}^{2z} \over 1 - \pars{1 - p}^{2}}& \mbox{if} & z & > & 0 
\end{array}\right.
\end{align}

\begin{align}&\color{#66f}{\large\left.%
\sum_{x\ =\ 0}^{\infty}\pars{1 - p}^{x}p\sum_{y\ =\ 0}^{\infty}\pars{1 - p}^{y}p
\right\vert_{\, z\ =\ x\ - y}}
=\color{#66f}{\large{p\pars{1 - p}^{\verts{z}} \over 2 - p}}
\end{align}

${\tt\mbox{We can check that}}$:
  \begin{align}
\sum_{z\ =\ -\infty}^{\infty}{p\pars{1 - p}^{\verts{z}} \over 2 - p}
&={p \over 2 - p}\bracks{1 + 2\sum_{z\ =\ 1}^{\infty}\pars{1 - p}^{z}}
={p \over 2 - p}\bracks{1 + 2\,{1 - p \over 1 - \pars{1 - p}}}
\\[5mm]&={p \over 2 - p}\,{2 - p \over p} = \color{#c00000}{\large 1}
\end{align}

