# Joint PMF of two discrete random variables (probably binomial and geometric?)

I am stuck on a problem, even after finding some similar examples.

The problem: An experiment is successful with probability $p$ and independent of the outcome of all other experiments. When $n$ experiments are done, let $K$ denote the number of failed experiments and let $X$ denote the number of successful experiments until the first failed experiment. What is the joint PMF $P_{K,X}(k,x)$?

From this information, I think I can say that $K$ is binomially distributed and $X$ has a geometric distribution. I have seen examples where the definition of conditional probability is used to find the joint PMF, $P(K=k,X=x)=P(K=k)\cdotp P(X=x|K=k)=P(X=x)\cdotp P(K=k|X=x)$. However, I have no idea how to go from here. $P(K=k)$ and $P(X=x)$ should be easy to find, but I am not really sure how to find either $P(X=x|K=k)$ or $P(K=k|X=x)$. It feels like I am missing some information.

I would appreciate it if somebody could point me in the right direction. I am not really interested in the answer, I just want to know how to tackle this type of problems.

Actually $X$ is not well defined because it is not stated what value it takes if all $n$ experiments succeed.

Let me preassume then that in that case $X$ takes value $n$

So if indeed $X$ takes value $n$ then $K=0$ so that $P(K=0\mid X=n)=1$ and consequently $P(K=k\mid X=n)=0$ for $k\neq0$.

If $X$ takes value $n-1$ then $K=1$ so that $P(K=1\mid X=n-1)=1$ and consequently $P(K=k\mid X=n-1)=0$ for $k\neq1$.

If $X$ takes some value $x\in\{0,1,\dots,n-2\}$ then the $x+1$-th experiment is the first one that fails. After that $n-x-1$ experiments will follow so that $K-1$ has binomial distribution with parameters $n-x-1$ and $1-p$.

That leads to $P(K=k\mid X=x)=P(K-1=k-1\mid X=x)=\binom{n-x-1}{k-1}p^{n-x-1-k}(1-p)^k$.

This all shows that your approach $P(K=k,X=x)=P(K=k\mid X=x)P(X=x)$ might bear fruit.

• Wow, that mostly makes sense to me. Thanks! I already had answer sheets for this exercise so I already knew what should have been the outcome, but it is slightly different from your answer. The answer sheet says $P_{K,X}(k,x)=\binom{n-x-1}{k-1}p^{n-k}(1-p)^k$ under the conditions that $x+k \leq n, x \geq 0, k \geq 0$ and otherwise it is zero. I am confused, is it actually the same because of the conditions added to it? If it is the case, I don't see why they are the same. I am sorry if this should all be very obvious, I do not have to work with probability very often. – Jari Aug 2 '17 at 18:51