Answers: Law of total probability and Bayes’ theorem
These are the answers to Questions: Law of total probability and Bayes’ theorem.
Please attempt the questions before reading these answers.
Q1
1.1.
You know:
- \(\mathbb{P}(\textsf{Ward A}) = 0.4\)
- \(\mathbb{P}(\textsf{Recover} \mid \textsf{Ward A}) = 0.8\)
- \(\mathbb{P}(\textsf{Ward B}) = 0.6\)
- \(\mathbb{P}(\textsf{Recover} \mid \textsf{Ward B}) = 0.6\)
Using the law of total probability:
\[ \mathbb{P}(\textsf{Recover}) = \left(\dfrac{4}{10}\right)\left(\dfrac{8}{10}\right) + \left(\dfrac{6}{10}\right) \left(\dfrac{6}{10}\right) = 0.32 + 0.36 = 0.68 \]
So the probability that a randomly chosen patient recovers is \(0.68\).
1.2.
You know:
- \(\mathbb{P}(\textsf{Veg}) = 0.5\), \(\mathbb{P}(\textsf{Finish} \mid \textsf{Veg}) = 0.9\)
- \(\mathbb{P}(\textsf{Chicken}) = 0.3\), \(\mathbb{P}(\textsf{Finish} \mid \textsf{Chicken}) = 0.7\)
- \(\mathbb{P}(\textsf{Fish}) = 0.2\), \(\mathbb{P}(\textsf{Finish} \mid \textsf{Fish}) = 0.8\)
Using the law of total probability:
\[ \mathbb{P}(\textsf{Finish}) = (0.5)(0.9) + (0.3)(0.7) + (0.2)(0.8) = 0.45 + 0.21 + 0.16 = 0.82 \]
So the probability that a randomly chosen student finishes their lunch is \(0.82\).
1.3.
You know:
- \(\mathbb{P}(F_1) = 0.2\), \(\mathbb{P}(\textsf{Defective} \mid F_1) = 0.05\)
- \(\mathbb{P}(F_2) = 0.3\), \(\mathbb{P}(\textsf{Defective} \mid F_2) = 0.02\)
- \(\mathbb{P}(F_3) = 0.5\), \(\mathbb{P}(\textsf{Defective} \mid F_3) = 0.01\)
Using the law of total probability:
\[ \mathbb{P}(\textsf{Defective}) = (0.2)(0.05) + (0.3)(0.02) + (0.5)(0.01) = 0.01 + 0.006 + 0.005 = 0.021 \]
So the probability that a randomly selected product is defective is \(0.021\).
1.4.
You know:
- \(\mathbb{P}(\textsf{Home}) = 0.5\), \(\mathbb{P}(\textsf{Complete} \mid \textsf{Home}) = 0.7\)
- \(\mathbb{P}(\textsf{Library}) = 0.3\), \(\mathbb{P}(\textsf{Complete} \mid \textsf{Library}) = 0.9\)
- \(\mathbb{P}(\textsf{Café}) = 0.2\), \(\mathbb{P}(\textsf{Complete} \mid \textsf{Café}) = 0.6\)
Using the law of total probability:
\[ \mathbb{P}(\textsf{Complete}) = (0.5)(0.7) + (0.3)(0.9) + (0.2)(0.6) = 0.35 + 0.27 + 0.12 = 0.74 \]
So the probability that the student completes their homework is \(0.74\).
Q2
2.1.
You know:
- \(\mathbb{P}(D) = 0.02\)
- \(\mathbb{P}(\textsf{Pos} \mid D) = 0.95\)
- \(\mathbb{P}(\textsf{Pos} \mid \neg D) = 0.1\) (where \(\neg D\) means the person does not have the disease)
- \(\mathbb{P}(\neg D) = 0.98\)
Using the law of total probability:
\[ \mathbb{P}(\textsf{Pos}) = (0.02)(0.95) + (0.98)(0.1) = 0.019 + 0.098 = 0.117 \]
Now applying Bayes’ theorem:
\[ \mathbb{P}(D \mid \textsf{Pos}) = \dfrac{(0.95)(0.02)}{0.117} \approx 0.162 \]
So the probability that the person has the disease, given that they test positive, is approximately \(0.162\). Not a very good test!
2.2.
You know:
- \(\mathbb{P}(\textsf{Rain}) = 0.4\)
- \(\mathbb{P}(\textsf{Dry}) = 0.6\)
- \(\mathbb{P}(F \mid \textsf{Rain}) = 0.8\)
- \(\mathbb{P}(F \mid \textsf{Dry}) = 0.1\)
Using the law of total probability:
\[ \mathbb{P}(F) = (0.4)(0.8) + (0.6)(0.1) = 0.32 + 0.06 = 0.38 \]
Then applying Bayes’ theorem gives:
\[ \mathbb{P}(\textsf{Rain} \mid F) = \dfrac{(0.8)(0.4)}{0.38} \approx 0.842 \]
So the probability that it actually rains in St Andrews, given that the forecast predicts rain, is approximately \(0.842\).
2.3.
You know:
- \(\mathbb{P}(A) = 0.7\)
- \(\mathbb{P}(B) = 0.3\)
- \(\mathbb{P}(F \mid A) = 0.02\)
- \(\mathbb{P}(F \mid B) = 0.05\)
Using the law of total probability:
\[ \mathbb{P}(F) = (0.7)(0.02) + (0.3)(0.05) = 0.014 + 0.015 = 0.029 \]
Then applying Bayes’ theorem gives:
\[ \mathbb{P}(B \mid F) = \dfrac{(0.05)(0.3)}{0.029} \approx 0.517 \]
So the probability that the broken biscuit came from Machine B, given that it is broken, is approximately \(0.517\).
2.4.
You know:
- \(\mathbb{P}(\textsf{Red}) = 0.4\)
- \(\mathbb{P}(\textsf{Blue}) = 0.6\)
- \(\mathbb{P}(W \mid \textsf{Red}) = 0.3\)
- \(\mathbb{P}(W \mid \textsf{Blue}) = 0.7\)
Using the law of total probability:
\[ \mathbb{P}(W) = (0.4)(0.3) + (0.6)(0.7) = 0.12 + 0.42 = 0.54 \]
Then applying Bayes’ theorem gives:
\[ \mathbb{P}(\textsf{Red} \mid W) = \dfrac{(0.3)(0.4)}{0.54} \approx 0.222 \] So the probability that the sweet is red, given that it has a wrapper, is approximately \(0.222\).
Version history and licensing
v1.0: initial version created 05/25 by Sophie Chowgule as part of a University of St Andrews VIP project.