# Distribution of number of Poisson arrivals in interval

$X_1$ and $X_2$ are both Poisson processes. $N$ is the number of arrivals of $X_1$ in between two subsequent arrivals of $X_2$. Derive the probability density $f_N(n)$ of $N$.

I wanted to start from $P(N=n)=P(X_1(t_2)-X_1(t_1)=n)$. I know $X_1(t_2)-X_1(t_1)$ has a Poisson distribution with expected value $\lambda (t_2-t_1)$. But the times $t_1$ and $t_2$are the arrival times of a Poisson process, so they're not known. I thought I should use a random variable $Y$, which is the time of arrival of the $k^{th}$ Poisson point. So this would have density $f_Y(t)=\frac{\lambda \exp(-\lambda t) (\lambda t)^{k-1}} {(k-1)!}$.

But I don't know how to proceed now. Any help?

Let $T$ denote the time between two successive $X_2$ arrivals, then $T$ is exponential with parameter $\lambda_2$ and, conditionally on $T=t$, the distribution of $N$ is Poisson with parameter $\lambda_1t$.
Thus, $E(s^N\mid T)=\mathrm e^{-\lambda_1T(1-s)}$ and $E(s^N)=E(\mathrm e^{-rT})$ with $r=\lambda_1(1-s)$. Recall that, for every $u\gt-\lambda_2$, $E(\mathrm e^{-uT})=\lambda_2/(\lambda_2+u)$, hence $E(s^N)=\lambda_2/(\lambda_2+\lambda_1(1-s))=p/(1-qs)$ with $p=\lambda_2/(\lambda_2+\lambda_1)$ and $q=1-p$, that is, $E(s^N)=p\sum\limits_{n\geqslant0}q^ns^n$.
Finally, $P(N=n)=p(1-p)^n$ for every $n\geqslant0$ and $N$ is geometric with parameter $\lambda_1/(\lambda_1+\lambda_2)$.
It might be worth mentioning that this result has a natural "physical" explanation (actually, a proof) where one realizes both Poisson processes simultaneously using a marked Poisson process with intensity $\lambda_1+\lambda_2$ whose each point is marked $1$ or $2$ with respective probabilities $q$ and $p$. Then $N-1$ is the rank of the first point marked $2$, and the geometric distribution of $N$ tediously computed above suddenly becomes obvious: for every $n\geqslant0$, the event $[N=n]$ happens when one choses $n$ times the mark $1$ and then the mark $2$, hence the probability $pq^n$.