# conditional probability involving mixed variable types

I'm trying to answer the following question

A defective coin minting machine produces coins whose probability of heads is a random variable $$T$$ with PDF $$f_{T}(p) = 1+\mathrm{sin}(2\pi p)$$ if $$p \in [0,1]$$ and $$f_{T}(p)=0$$ otherwise.

In essence a specific coin produced by this machine will have a fixed probability $$T=p$$ of giving heads,but you do not know initially what that probability is. A coin produced by this machine is selected and tossed repeatedly, with successive tosses assumed independent.

a.Find the probability that the first coin toss results in heads.

b.Given that the first coin toss resulted in heads, find the conditional PDF of $$T$$.

c.Given that the first coin toss resulted in heads, find the conditional probability of heads on the second toss.

Now i've worked out the solutions to the three questions. I'm going through the actual solutions and i'm confused as to how they've arrived at a particular point in the solution for part c). As they did theirs differently to me i really wanted to understand their approach too.

The solution is here

How did they arrive at the part $$P(B|A) = \int^{1}_{0} P(B|T=p,A) f_{T|A}(p)dp$$? (note i've switched $$P$$ with $$T$$ to not confuse it with the probability $$P$$)? For some reason i'm convinced it should be

$$P(B|A) = \int^{1}_{0} P(B|T=p,A) f_{T}(p)dp$$ and my reasoning is if we let $$C = (B|A)$$ then $$P(C) = \int^{1}_{0} P(C|T=p) f_{T}(p) dp$$ from the continuous version of the law of total probability. Can someone please explain the answer perhaps with a proof and why my reasoning is invalid. Note this is not for any homework assignment i'm just keen to sharpen my skills in probability theory and i want to understand their approach step by step.

Note my solution was

$$P(B|A) = P(A,B)/P(A) = \frac{\int^{1}_{0} P(A,B|T=p) f_{T}(p)}{P(A)} dp$$ which is easier to work with. Regarding their solution

My thinking is they may have got it somewhere like the following.

$$P(B|A) = \frac{\int^{1}_{0} P(A,B,T=p) dp}{P(A)} = \frac{\int^{1}_{0} P(B|A,T=p)P(A,T=p)}{P(A)}$$

Now my guess would be they derived the conditional density distribution from the last part? It looks similar but i realise there is subtleties involved with mixing probabilities and densities. If this is the case i'd be grateful to see the proof thanks!

The solution is hidden in the line below

A coin produced by this machine is selected and tossed repeatedly, with successive tosses assumed independent

To be more concrete, let the random variable be defined as below

$$B$$ = Result of the second coin toss

$$A$$ = Result of the first coin toss

$$T$$ = Probability of the extracted coin

• If the value of $$T$$ is given beforehand, then, the problem becomes finding $$P(B = H | A=H, T=p)$$, which is equal to $$P(B = H | T=p) = p$$ because the toss results are independent once the value of $$T$$ is known
• But the question asks a different thing, which is to find $$P(B=H|A=H)$$, in this case, the value of the random variable $$T$$ could be anything, in essence, it becomes similar to part (a) in which it was asked to calculate $$P(A=H)$$
• Therefore, we need to marginalize $$f_{BT|A=H}(b,p)$$ on all of $$T$$ to calculate $$P(B|A=H)$$, since $$f_{BT|A=H}(b,p) = f_{B|T=p,A=H}(b)\ . \ f_{T|A=H}(p)$$, and since $$A$$ and $$B$$ are independent given $$T$$, $$f_{BT|A=H}(b,p) = f_{B|T=p}(b)\ . \ f_{T|A=H}(p)$$

Also, $$f_{B|T=p}(b=H) = p$$, which makes the solution $$P(B=H|A=H) = \int_{0}^{1}p.f_{T|A=H}(p) dp \\ = \int_{0}^{1}p.\frac{p.(1+sin(2\pi p))}{\frac{\pi - 1}{2\pi}} dp \\ = \frac{2\pi}{\pi - 1}\int_{0}^{1}p^2.(1+sin(2\pi p)) dp \\ = \frac{2\pi - 3}{3 \pi - 3}$$

How did they arrive at the part $$P(B|A) = \int^{1}_{0} P(B|T=p,A) f_{T|A}(p)dp$$?

Conditioning on A has to be respected in both terms under the integral, hence the correct use of $$f_{T|A}(p)$$.

Replacing $$A|B$$ with $$C$$ is not propagated correctly in your expressions and hides the conditioning.

• Could you show me a derivation by adding in the extra steps?
– Iltl
Commented Mar 28, 2019 at 9:48
• To me like i said the derivation might look like the chain rule for multiple variables, but with density functions. I just wanted to see how it was arrived at.
– Iltl
Commented Mar 28, 2019 at 10:00
• Too much for me to write a complete answer. Please see the added image above. The book is "Basic Probability Theory" by Robert Ash. Commented Mar 28, 2019 at 17:24