Rudolf Adamkovič Personal site


Law of total probability

Define

\[\begin{equation*}
  P(A) = P(A | B) \, P(B) + P(A | \lnot B) \, P(\lnot B).
\end{equation*}
\]

Prove

  1. Define probabilities of events \(A\) and \(B\) as
    \[\begin{equation*}
      \begin{array}{r|cc}
        & B & \lnot B \\ \hline
        A & s & t \\ \lnot A & u & v.
      \end{array}
    \end{equation*}
    \]
  2. Substitute \(s, t, u, v\) into the law
    \[\begin{equation*}
      \begin{array}{ccccccccc}
        P(A) & = & P(A | B) & \cdot & P(B) & + & P(A | \lnot B) & \cdot & P(\lnot B)
        \\[3ex]
        \begin{array}{cc} \boxed{s} & \boxed{t} \\ u & v \end{array}
        & = & \begin{array}{cc} \boxed{s} & \bcancel{t} \\ u & \bcancel{v} \end{array}
        & \cdot & \begin{array}{cc} \boxed{s} & t \\ \boxed{u} & v \end{array}
        & + & \begin{array}{cc} \bcancel{s} & \boxed{t} \\ \bcancel{u} & v \end{array}
        & \cdot & \begin{array}{cc} s & \boxed{t} \\ u & \boxed{v} \end{array}
        \\[3ex]
        \dfrac{s + t}{s + t + u + v}
        & = & \dfrac{s}{s + u} & \cdot & \dfrac{s + u}{s + t + u + v}
        & + & \dfrac{t}{t + v} & \cdot & \dfrac{t + v}{s + t + u + v}.
      \end{array}
    \end{equation*}
    \]
  3. Verify the equality
    \[\begin{align*}
        \frac{s + t}{s + t + u + v}
        & \stackrel{?}{=}
        \frac{s}{s + u}
        \cdot
        \frac{s + u}{s + t + u + v}
        +
        \frac{t}{t + v}
        \cdot
        \frac{t + v}{s + t + u + v}
        \\[2ex]
        \frac{s + t}{s + t + u + v}
        & =
        \frac{s \cancel{(s + u)}}{\cancel{(s + u)} (s + t + u + v)}
        +
        \frac{t \cancel{(t + v)}}{\cancel{(t + v)} (s + t + u + v)}
        \\[2ex]
        \frac{s + t}{s + t + u + v}
        & =
        \frac{s}{s + t + u + v}
        +
        \frac{t}{s + t + u + v}
        \\[2ex]
        \frac{s + t}{s + t + u + v}
        & =
        \frac{s + t}{s + t + u + v}.
        \\[2ex]
        1
        & \stackrel{\checkmark}{=}
        1.
    \end{align*}
    \]

\(\blacksquare\)

Use

A person tests positive for a disease.

What is the probability of the person having the disease?

Let

\(t\)denote the event “tests positive” and
\(d\)denote the event “has the disease”.

We know that

\[\begin{align*}
  P(d) & = 1 / 5000 = 0.0002, && \text{\(1\) in \(5000\) prevalence} \\
  P(t | d) & = 0.99, && \text{\(99\%\) true positives} \\
  P(\lnot t | \lnot d) & = 1. && \text{\(100\%\) true negatives}
\end{align*}
\]

We must find

\[\begin{equation*}
  P(d | t).
\end{equation*}
\]

N.B. We cannot use the Bayes’ Theorem right away because \(P(t)\) is unknown.

  1. Find the probability of false positives
    \[\begin{equation*}
      P(t | \lnot d) = 1 - P(t | d) = 1 - 0.99 = 0.01.
    \end{equation*}
    \]
  2. Find the probability of not having the disease
    \[\begin{equation*}
      P(\lnot d) = 1 - P(d) = 1 - 1 / 5000 = 0.9998.
    \end{equation*}
    \]
  3. Find the probability of testing positive
    \[\begin{align*}
      P(t)
      & = P(t | d) \, P(d) + P(t | \lnot d) \, P(\lnot d) \\
      & = 0.99 \cdot 0.0002 + 0.01 \cdot 0.9998 \\
      & = 0.010196
    \end{align*}
    \]

    using the law of total probability.

  4. Find the probability of having the disease given a positive test
    \[\begin{equation*}
      P(d | t)
      = \frac{P(d) \, P(t | d)}{P(t)}
      = \frac{0.0002 \cdot 0.99}{0.010196}
      \approx 0.0194193 \\
      = 2\%
    \end{equation*}
    \]

    using the Bayes’ theorem.

(Webb & Sidebotham, 2020)



© 2024 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.