# Series of Bernoulli random variables has geometric distribution

I try to solve the following task:

Let $p\in ]0,1[$ and $X_1,X_2,\dots,Y_1,Y_2,\dots$ be i.i.d. Bernoulli$(p)$ random variables. We define $N:=\min\{n\in\mathbb{N}:X_n\neq Y_n\}$ and set $$Z:=X_N=\sum\limits_{n=1}^\infty \mathbb{1}_{\{N=n\}}X_n$$ where $1$ is the indicator function.

1. Check that $N\geq 1$ has the geometric distribution with parameter $2p(1-p)$
2. Show that $Z$ has Bernoulli$(1/2)$ distribution

3. Deduce a way to simulate a fair coin toss using a potentially unfair coin.

My attempt:

We are interested in the case where after $n-1$ steps the $X_n\neq Y_n$.

$P(X_1=Y_1,\dots, X_n\neq Y_n)=P(X_1=Y_1)\cdots P(X_n\neq Y_n)$

I can view $Z:=X_i=Y_i$ as a Bernoulli experiment since it is either true or not. So I want to find out, at which step $P(Z_n)=1-p$ So I have $$P(Z_1)\cdots P(Z_n)=P(X_1=Y_1)\cdots P(X_n\neq Y_n)=p^{n-1}(1-p)$$ Which is the geometric distribution with parameter $q:=1-p$.

But I don't know why it should have parameter $2p(1-p)$ and how the rest works.

• The probability $X_k$ and $Y_k$ are different is the probability $X=1$ and $Y=0$ plus the probability $X=0$ and $Y=1$. Each of these events has probability $p(1-p)$. Apr 14, 2016 at 14:16

$1.$ The probability $X_k$ and $Y_k$ are different is the probability $X_k=1$ and $Y_k=0$ plus the probability $X_k=0$ and $Y_k=1$. Each of these events has probability $p(1-p)$.
So if $a=2p(1-p)$, then $\Pr(N=k)=(1-a)^{k-1}a$.
$2.$ We can give a more common-sense description of $Z$. We have $Z=1$ if the first time $n$ that $X_n$ and $Y_n$ are different, we have $X_n=1$.
Given that $X_n\ne Y_n$, the events $(X_n=1\cap Y_n=0)$ and $(X_n=0\cap Y_n=1)$ are equally likely. So $\Pr(Z_n=1)=\frac{1}{2}$.
$3.$ Toss the coin once, toss it again. If the first toss is Head and the second is Tail, declare A has won. If the first toss is Tail and the second is Head, declare B has won. If the two tosses are identical, repeat the experiment. Continue until someone has won. Use the result of 1) to show that with probability $1$ the game terminates.