Choosing a Threshold
Part A
You wake up feeling a bit of a tickle in your throat. You take a COVID rapid test. Consider two scenarios:
- The test comes up positive and you quarantine for five days. As it turns out, your throat tickle disappears after 1 day, and a lab test reveals that you did not actually have COVID.
- The test comes up negative. You figure you must just have a common cold. You carry on your day as usual. After 5 days, you decide to get a lab test, which reveals that you have been COVID+ for the last 5 days.
Using any assumptions that seem appropriate to you, assign a numerical cost to each of these scenarios. If it helps, you may assume that scenario (a) is 1 “unit of badness,” and that scenario (b) is \(k\) times as bad as scenario (a). What’s your suggested value of \(k\)?
Please write down your reasoning and your suggested value in a short paragraph.
Part B
Let’s now imagine that the rapid COVID test does not just give a yes/no answer, but actually a score describing the patient’s likelihood of COVID on a scale from 0 to 1. What score is high enough to merit you staying home, according to your costs from Part A? To answer this question, run the following code to create a simulated vector of cases
(0 is COVID negative, 1 is COVID positive) and scores
between 0 and 1.
import numpy as np
= 1000
NUM_CASES = 0.1
PREVALENCE = 2
NOISE
= 1*(np.random.rand(NUM_CASES) < PREVALENCE)
cases = np.exp(cases + NOISE*(np.random.rand(NUM_CASES))) / np.exp(NOISE+1) scores
Suppose that the recommendation on the rapid test is that a score above \(t\) indicates a “positive” result and that you should quarantine.
- Write a function which, given a candidate value of \(t\), computes the total “cost” of using that threshold. The cost is equal to the number of times scenario (a) occurs in this data set (from Part A), multiplied by the cost of scenario (a), plus the number of times scenario (b) occurs in this data set, multiplied by the cost of scenario (b).
- Using a
for
-loop or any other technique, conduct a search to find the value of \(t\) that minimizes the total cost.
© Phil Chodrow, 2025