Conditional probability distribution with geometric random variables [duplicate]

Let X and Y are independent random variables following geometric distribution with parameter p. Find the distribution of X given that X + Y = n.

I made it this expression... $$P\{X =i|X+Y=n\}=\frac{(1-p)^2p^2}{P(X+Y=n)}$$

I do not know how to proceed now


I will assume that $X$, $Y$ are the numbers of trials until the first success, where the probability of success on any trial is $p$. Then $\Pr(X=j)=\Pr(Y=j)=(1-p)^{j-1}p$.

Let $A$ be the event $X=i$ and let $B$ be the event $X+Y=n$. Then by the definition of conditional probability, we have $$\Pr(A|B)=\frac{\Pr(A\cap B)}{\Pr(B)}.$$ The probability of $A\cap B$ is easy to compute. It is $\Pr(X=i)\Pr(Y=n-i)$. This is $(1-p)^{i-1}p(1-p)^{n-i-1}p$, which simplifies to $(1-p)^{n-2}p^2$.

For the probability that $X+Y=n$, we can use the fact that $$\Pr(X+Y=n)=\Pr(X=1)\Pr(Y=n-1)+\Pr(X=2)\Pr(Y=n-2)+\cdots +\Pr(X=n-1)\Pr(Y=1).$$ This simplifies to $(n-1)((1-p)^{n-2}p^2$.

Divide. We get $\frac{1}{n-1}$. The conditional probability is discrete uniform. One can save a little time in the calculation of $\Pr(X+Y=n)$ by noting that $X+Y$ has negative binomial distribution: it is the number of trials until the second success.

Remark: If you define the geometric with parameter $p$ as the number of failures until the first success, the calculation is very similar. Again we get a uniform distribution, this time on $\{0,1,2,\dots,n\}$.

Edit: From a comment, it is now clear that the geometric here counts the number of failures until the first success. Small details of the calculation above change, we use $(1-p)^i p(1-p)^{n-i}p$ for $\Pr(X=i)\Pr(Y=n-i)$. We get that the conditional probability is $\frac{1}{n+1}$ for $i=0$ to $n$.