Skip to main content
Biology LibreTexts

3.4: Conditional Probability, Bayes Rule, and Genetic Testing

  • Page ID
    142413
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    As our understanding of the genetic basis of heritable diseases has increased, so has the interest in genetic testing -- molecular diagnostics that can tell a physician or genetic counselor whether a person has a genetic disease or is a carrier of a disease-releated allele. However, no diagnostic test is 100% accurate! To understand how the accuracy (or not!) of a test influences how we interpret its results, we need to discuss two closely related topics: conditional probability and Bayes rule.

    Conditional Probability

    What is the probability that event A happens and event B happens? Remember, this is the joint probability of A and B, and thus far we've only been able to answer if events A and B are independent:

    \[ P(A \text{ and } B) = P(A) \cdot P(B) \]

    However, there are many times that we are interested in the joint probability of A and B when A and B are not independent! Sampling without replacement is one example:

    Example \(\PageIndex{1}\)

    I have a box containing two white balls and two black balls. I draw two balls without looking. What is the probability that I draw a white ball and then a black ball?

    Solution

    Let event A be "the first ball is white" and event B be "the second ball is black" The probability of drawing a white ball is 2 / 4, or 0.5 However, since A has happened, now there is one white ball and two black balls -- so the probability of B if A has already occurred is now 2/3, or 0.66. We would write this as:

    \[ P(A) = 0.5 \]

    \[ P(B | A) = 0.66 \]

    That is to say, the probability of A is 0.5, and the probability of B is also 0.5, but the probability of B given A is 0.66.

     

    In general, we can compute the conditional probability of event A given the occurrence of event B using the following formula:

    \[ P(A|B) = \frac{P(A \text{ and } B)}{P(B)} \]

    It is also useful to rearrange the above formula to compute the joint probability of A and B, given the probability of A given B and the probability of B:

    \[ P(A \text{ and } B) = P(A|B) \cdot  P(B) \]

    Note that the "and" in \( P(A and B) \) is transitive, and the following is also true:

    \[ P(A \text{ and } B) = P(B|A) \cdot  P(A) \]

    Finally, the idea of conditional probability allows us to define the independence of two events more concretely: Events A and B are independent if and only if \( P(A) = P(A|B) \). That is to say, whether or not event B happens has no impact on the probability of event A happening. 

    Total Probability

    Recall that \( \neg A \) means "not A", and that \( P(A) + P(\neg A) = 1 \). That is to say, an event either happens or it doesn't -- these outcomes are mutually exclusive -- and the probability that an event happens or it doesn't happen is 1. If we consider the conditional probability that A happens given B happens, and the conditional probability that A happens given that B didn't happen, it should be clear that

    \[ P(A) = P(A \text{ and } B) + P(A \text{ and } \neg B) = P(A|B) \cdot  P(B) + P(A|\neg B) \cdot  P(\neg B) \]

    B either happens or it doesn't. Those outcomes are mutually exclusive. The probability that A happens and B happens, plus the probability that A happens and B does not happen, is the same as the probability of A.

     

    Bayes Rule

    Note that \( P(A \text{ and } B) = P(A|B) \cdot  P(B) \) and \( P(A \text{ and } B) = P(B|A) \cdot  P(A) \). What if we set them equal and do some rearranging?

    \[ P(B|A) \cdot  P(A) = P(A|B) \cdot  P(B) \]

    \[ P(B|A) = \frac{ P(A|B) \cdot  P(B) }{ P(A) } \]

    This last is called Bayes' Rule or Bayes' Theorem and it is the basis of an entire branch of statistics called Baysian statistics. It is often useful to expand the denominator \( P(B) \) using the rule of total probability to get

    \[ P(B|A) = \frac{ P(A|B) \cdot  P(B) }{ P(A|B) \cdot  P(B) + P(A|\neg B) \cdot  P(\neg B) } \]

    Bayes' Rule is important because it gives us ways to manipulate conditional probabilities. For example, we could ask a question such as "what is the probability that I don't have COVID, given that my COVID test is negative?" That example is worked below.

     

    Example \(\PageIndex{1}\)

    "What is the probability that I don't have COVID, given that my COVID test is negative?" We need some additional information to answer this question.

    • Let's assume that the false negative rate of a COVID test is 10% -- eg, if you have COVID, there is a 10% chance the test will be negative.
    • Let's also assume that the false positive rate of a COVID test is 0% -- if you don't have COVID, there is a 100% chance the test will be negative.
    • We also need the base rate -- the chance that, absent the information provided by a COVID test, you would be infected. Let's assume that we're in the middle of a surge right now and that the base rate is 5%, or 0.05.
    • The last thing, and sometimes the trickiest, is to decide what my events are. Let's have event B be "I have COVID" and event A be "my test was negative."

    Now we can set up the Bayes' Rule computation:

    • \( P(B|A) \) is the probability that I have COVID, given that my test was negative.
    • \( P(A|B) \) is the probability that the test is negative, given that I have COVID -- that's the false negative rate, 0.1
    • \( P(B) \) is the probability that I have COVID without any additional information -- it's our base rate, 0.05.
    • \( P(A|\neg B) \) is the probability that my test is negative given that I DON'T have COVID -- it's the complement of our false positive rate, which is 1.0
    • \( P(\neg B) \) is the complement of the base rate -- 0.95

    Now we plug and chug, using the "expanded" version of Bayes' Rule:

    \[ P(B|A) = \frac{0.1 \cdot 0.05}{0.1 \cdot 0.05 + 1.0 \cdot 0.95 } = \frac{0.005}{0.005 + 0.95} = 0.005 \]

    Let's take a moment and appreciate what we did here. If we chose a person randomly from the population, there is a 5% chance they have COVID. And then we tested them -- and their test was negative. This gave us additional information about the situation, and with that additional information, there is now a 0.5% chance they have COVID. Becuase the test was perfect, we are still not 100% sure -- but we are substantially more sure about the probability.

    In other words, we started with a prior view or hypothesis about the world. We got more information. And we used that information to update our hypothesis. More specifically, we call \( P(B) \) in the example above our prior probability -- our view of the world before we get more information -- and \( P(B|A) \) is the posterior probability, our view of the world after we get more information.

    And one more thing. "Getting more information" can be a genetic test, but there's lots of other "more information" that we can use to update our priors. We'll see a number of examples in this chapter's problems, and even more through the rest of the semester.

     

     


    3.4: Conditional Probability, Bayes Rule, and Genetic Testing is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?