# Probability of two independent random variables being equal

Assume that $X$ and $Y$ are two independent random variables that follow the binomial distribution of parameters $p$ (the probability of one success) and $n$ (the number of trials).

I was wondering if there is a way of expressing the probability that $X=Y$, other than summing up all the cases when $X=Y=k$, with $k$ from $0$ to $n$, which will give the formula $$\sum_{k=0}^{n}\binom{n}{k}^{2}p^{2k}(1-p)^{2n-2k}.$$

Edit: I'm not interested in computing or rewriting the sum above using some algebraic tricks, but in finding another probabilistic or combinatorial approach to the problem that would yield another (maybe "nicer") answer.

-

You can factor out constants wrt $k$ and remain with the expression of the form $$\sum_{k=0}^{n}\binom{n}{k}^2x^k$$ which unfortunately doesn't have a closed form. See here for some details. You will see more links in the answer to the question there.