I was studying probability theory (more specifically joint distributions), and came across an exercise problem that I managed to almost solve, but am having trouble understanding a part of the solution. Allow me to elaborate. Here's the exercise problem (paraphrased):
(Source: Introduction to Probability (1e) - Blitzstein & Hwang)
There are two doctors, Dr. Hibbert and Nick. They are called upon to perform $n$ surgeries. Let $H$ be the indicator random variable for Dr. Hibbert performing the surgery, and suppose that $E(H) =p$. Given that Hibbert performs the surgery, each surgery is successful with probability $a$, independently, and with probability $b$ in case Nick performs the surgery, again independently. Let $X$ be the number of successful surgeries.
(a) Find the joint PMF of $H$ and $X$.
(b) Find the marginal PMF of $X$.
(c) Find the conditional PMF of $H$ given $X=k$.
When I solved this, I managed to get the answer for (b),
\begin{align} P(X=k) & = P(X=k,\ H=0)\ +\ P(X=k,\ H=1) \\ & = P(X=k\ |\ H=0)P(H=0)\ +\ P(X=k\ |\ H=1)P(H=1) \\ & =\left(\binom{n}{k}b^k(1-b)^{n-k}\times (1-p)\right)\ +\ \left(\binom{n}{k}a^k(1-a)^{n-k}\times p\right) \\ \end{align}
which makes sense because the success of a particular number of surgeries would depend on how many were performed by each doctor. I'm having trouble understanding the answer for (a).
The solution gives two answers for each case of $H$ (i.e. for $H=1$ and $H=0$). The left portion of $P(X=k)$ for $H=1$, and the right side for $H=0$.
How should I understand this? Does this mean we're simply taking into account two different cases of PMFs, and the marginal PMF of $X$ is simply combining these two?
Any feedback is appreciated. Thank you.
The joint PMF is $$p_{HX}(h,x)=P(H=h,X=x),$$ with $h\in\{0,1\}$ and $x\in \{0,1,\ldots,n\}$.
We can write this in terms of conditional probability as $$p_{HX}(h,x)=P(X=x|H=h)P(H=h).$$
Since $E(H)=p$ we know that $P(H=1)=p$ and $P(H=0)=1-p$. Then, for $h=1$ (Hibbbert), we have $$p_{HX}(1,x)=P(X=x|H=1)P(H=1)={n \choose x}a^x(1-a)^{n-x}p,$$ and if $h=0$ (Nick), $$p_{HX}(0,x)=P(X=x|H=0)P(H=0)={n \choose x}b^x(1-b)^{n-x}(1-p).$$
Now, the marginal PMF of $X$ is given by $$p_X(x)=\sum_{h=0}^1 p_{HX}(h,x)={n \choose x}b^x(1-b)^{n-x}(1-p)+{n \choose x}a^x(1-a)^{n-x}p,$$ and the conditional distribution of $H$ given $X=k$ is $$p_{H|X=k}(h)=\frac{p_{HX}(h,k)}{p_X(k)},$$ that is $$p_{H|X=k}(h)=\left\{\begin{matrix}\frac{{n \choose k}b^k(1-b)^{n-k}(1-p)}{{n \choose x}b^x(1-b)^{n-x}(1-p)+{n \choose x}a^x(1-a)^{n-x}p}&h=0\\\frac{{n \choose k}a^x(1-a)^{n-k}p}{{n \choose k}b^k(1-b)^{n-k}(1-p)+{n \choose k}a^k(1-a)^{n-k}p}&h=1.\end{matrix}\right.$$