Homework 8

  • Type your name and email in the “Student details” section below.

  • Develop the code and generate the figures you need to solve the problems using this notebook.

  • For the answers that require a mathematical proof or derivation you can either:

    • Type the answer using the built-in latex capabilities. In this case, simply export the notebook as a pdf and upload it on gradescope; or

    • You can print the notebook (after you are done with all the code), write your answers by hand, scan, turn your response to a single pdf, and upload on gradescope.

  • The total homework points are 100. Please note that the problems are not weighed equally.


  • This is due before the beginning of the next lecture.

  • Please match all the pages corresponding to each of the questions when you submit on gradescope.

Student details

  • First Name:

  • Last Name:

  • Email:

Problem 1 - Medical test analysis

Disclaimer: This example is a modified version of the one found in a 2013 lecture on Bayesian Scientific Computing taught by Prof. Nicholas Zabaras. I am not sure where the original problem is coming from.

We are tasked with assessing the usefulness of a tuberculosis test. The prior information I is:

The percentage of the population infected by tuberculosis is 0.4%. We have run several experiments and determined that:

  • If a tested patient has the disease, then 80% of the time the test comes out positive.

  • If a tested patient does not have the disease, then 90% of the time the test comes out negative.

To facilitate your analysis, consider the following logical sentences concerning a patient:

A: The patient is tested and the test is positive.

B: The patient has tuberculosis.

A. Find the probability that the patient has tuberculosis (before looking at the result of the test), i.e., \(p(B|I)\). This is known as the base rate or the prior probability.


B. Find the probability that the test is positive given that the patient has tuberculosis, i.e., \(p(A|B,I)\).


C. Find the probability that the test is positive given that the patient does not have tuberculosis, i.e., \(p(A|\neg B, I)\).


D. Find the probability that a patient that tested positive has tuberculosis, i.e., \(p(B|A,I)\).


E. Find the probability that a patient that tested negative has tuberculosis, i.e., \(p(B|\neg A, I)\). Does the test change our prior state of knowledge about about the patient? Is the test useful?


F. What would a good test look like? Find values for

\[ p(A|B,I)= p(\text{test is positive} |\text{has tuberculosis},I), \]


\[ p(A| \neg B, I) = p(\text{test is positive}|\text{does not have tuberculosis}, I), \]

so that

\[ p(B|A, I) = p(\text{has tuberculosis}|\text{test is positive}, I) = 0.99. \]

There are more than one solutions. How would you pick a good one? Thinking in this way can help you set goals if you work in R&D. If you have time, try to figure out whether or not there exists such an accurate test for tuberculosis