# Help with Textbook question on conditional probability

I'm currently trying to learn Bayesian statistics and am working through the book "Bayesian Data Analysis". At the end of chapter 1 is a question asking to derive a conditional probability. I can't figure out the answer even though there is a printed solution here (question 1.3).

I'm not going to post the exact text of the question due to fear of copyright issues but it is roughly as follows:

| Gene 1 | Gene 2 | Trait |
|---     |---     |---|---|
| X      | X      | A     |
| X      | Y      | B     |
| Y      | X      | B     |
| Y      | Y      | B     |


In particular you are classed as a heterozygote if you have either XY or YX. A proportion $p^2$ of people have trait A and $2p(1-p)$ are heterozygote carriers of a single recessive allele where $0 < p < 1$. There is a 50/50 chance on either gene being passed on from parents to children.

Show that probability of a child being heterozygote given that they are B and their parents are both B is $2p/(1+2p)$

For my attempt so far I have the following:

For ease I've used the following notation
H = child is a heterozygotes
B = child has trait B
P = parents have trait B

\begin{align} P( H | B , P ) &= \frac{P( H , B , P)}{P(B,P)} \\ \\ &= \frac{P( B | H , P ) P(H , P ) }{ P(B | P) P(P) } \\ \\ &= \frac{1 * P(H | P ) P(P) }{ P(B | P) P(P) } \\ \\ &= \frac{P(H | P )}{ P(B | P) } \\ \end{align}

Also I calculate that the proportion of the population who are YY should be $(1-p)^2$.

From here I am stuck on where to go; my guess would be to use the law of total probability to calculate each conditional probability but I get lost whenever I attempt the algebra. Additionally when I look at the above linked solution I don't appear to be even on the right line. Any help would be appreciated.

You're right so far, so you can certainly start from trying to evaluate the final expression you wrote.

As you know, scenario $P$ entails three possibilities that are mutually exclusive. They are:

1. two heterozygous parents
2. two parents of type YY
3. one YY and one heterozygous parent

Let's call those scenarios $P_1,$ $P_2,$ and $P_3$ respectively. Then, $$P(P) = P(P_1) + P(P_2) + P(P_3).$$

The law of total probability states, $$P(H \mid P) = P(H,P_1 \mid P) + P(H,P_2 \mid P) + P(H,P_3 \mid P),$$ which we could rewrite as, $$P(H \mid P) = \frac{1}{P(P)} \left[P(H \mid P_1) P(P_1) + P(H \mid P_2) P(P_2) + P(H \mid P_3) P(P_3)\right].$$ Here, I used $P(H, P_1 \mid P) = P(H \mid P_1, P) P(P_1 \mid P) = P(H \mid P_1) P(P_1) / P(P).$

You can use the same logic for $P(B \mid P).$

If you let $q = 2 p (1-p)$ and $w = (1-p)^2$ then you can show that $P(P_1) = q^2,$ $P(P_2) = w^2,$ and $P(P_3) = 2 q w.$ Then you can work out $P(H \mid P_i)$ and $P(B \mid P_i)$ with the assumption that there's a $1/2$ chance of getting either gene from each parent. (For example, $P(B \mid P_1) = 3/4.$ If both parents are heterozygous, then there's only a $1/4$ chance of the child getting both X genes, which is the only way the child can have trait A.)

I think it's easier if you write $\frac{P(H \mid P)}{P(B \mid P)}$ in terms of $q$s and $w$s as I defined above, then convert them back into $p$s once you have the expression written out.

• That you for this it makes complete sense ! – gowerc Jan 12 '18 at 23:40
• As a side note how simple / hard is a question like this. For being the third question in a Bayesian text book it seemed pretty steep to me ! Is this a sign of things to come for Bayesian analysis ? – gowerc Jan 12 '18 at 23:42