I'm going through Bertsekas' and Tsitsiklis' "Introduction to Probability" and I'm stuck understanding a problem. This is not homework, and I have the solution. But I don't understand it, and I wonder if I am missing something or if there is an error.
A coin minting machine produces coins whose probability of heads is a random variable with density $f_P(p) = pe^p$ for $0 < p < 1$. Given that the first toss resulted in heads, find the conditional probability that of heads on the next one.
I am summarizing the solution a bit. Let $A$ be the event that the first flip is heads. Let $B$ be the event that the second flip is heads.
We use the continuous law of total probability to calculate $Pr(A) = e - 2$.
Using Bayes theorem:
$$ \begin{align} f_{P|A}(p) &= \frac{P(A|P=p)f_P(p)}{Pr(A)} \\ &= \frac{p^2 e^p}{e - 2} \end{align} $$
Finally, we use continuous total probability to compute
$$ \begin{align} Pr(B|A) &= \int_0^1 Pr(B|P=p, A) f_{P|A}(p) \mathrm{d}p \\ &= \int_0^1 Pr(B|P=p) f_{P|A}(p) \mathrm{d}p \\ &= \frac{1}{e-2} \int_0^1 p^3 e^p \mathrm{d}p \end{align} $$
I am confused about these integrals. In particular, it seems to me that either the first or second ones are wrong. If the first one is right, how are we justified in dropping the dependence on $A$ in the second integral?