# Probability of Equal Heads and Tails

I am having trouble with a probability problem: "Consider a coin which has probability p of coming up heads on a single flip. Suppose that A flips this coin n times and records the sequence of heads and tails and then B flips the same coin n times and records the sequence of heads and tails. Compute (in terms of n and p) the probability that B’s sequence of heads and tails is the same as A’s sequence of heads and tails. Your final answer should not involve any sums. "

At any point in time, the next flip will be independent of the previous toss's result. In any one combinations, if we consider a possibility of x Hs and n-x Ts, then there are nCx * (p^x) * (1-p)^(n-x) combinations of these types. So for a given pattern with x Hs and n-x Ts to occur the Probability is nCx * (p^x) * (1-p)^(n-x). I am stuck at the part where to figure out "given that A shows any pattern with x Hs and n-x Ts, the probability that B shows the same"

• Welcome to stackexchange. Please edit the question to show us what you have tried. In particular, can you work out the answer for very small values of $n$ and $k$? If you show some of your own effort we are more likely to want to help you. – Ethan Bolker Nov 6 '18 at 23:45

The correct solution to this problem is much simpler. Let us for now ignore the number of coin flips. Assume A and B both flip a coin. What is the probability that they come up with the same value? Well, if they come up with the same value then either both are heads or both are tails. These events are disjoint, so we can simply sum their probabilities: $$p^2 + (1-p)^2$$.
This tells us that if we consider a particular pair of coin flips, A and B have a $$p^2 + (1-p)^2)$$ chance of agreeing. Now the experiment above can be modeled as $$n$$ of these pairs of coin flips occurring in sequence. Since all pairs are independent and must agree, the probability of this happening is $$\left(p^2+(1-p)^2\right)^n$$.