# 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 1, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9974132180213928, "perplexity": 436.69622016430566}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-47/segments/1573496668765.35/warc/CC-MAIN-20191116204950-20191116232950-00052.warc.gz"}