Rapid Test Bayesian Updating Lab

Bayes’ rule is easiest to see as repeated updating. Start with a prior probability for a hidden state, record one observation, then use the posterior as the next prior.

This lab uses a rapid diagnostic test as the running example. The hidden state is whether a person has the disease. Each test returns one of two observations, positive or negative. The controls let you change the prevalence, sensitivity, and specificity, then watch how the interpretation of the same test result changes.

This is a probability demo, not medical guidance. The repeated-test calculations assume that test errors are conditionally independent given the true health state. Once the true state is fixed, each test is being treated as a fresh piece of evidence. In practice, sampling quality, test batch, timing, and shared biological factors can make repeated tests less independent than the idealized model.

Interactive

Sensitivity is the true positive rate, while specificity is the true negative rate. A positive result uses $\mathbb{P}(+\mid D^\prime)=1-\mathrm{specificity}$, so lowering specificity directly raises the false positive rate.
Current $\mathbb{P}(D)$
Last update
Disease $D$
No disease
StepResultPrior$\mathbb{P}(E\mid D)$$\mathbb{P}(E\mid D^\prime)$Posterior
Click a result button to start the update path.

What it shows

One observation, one update. A positive test is evidence for disease, but the strength of that evidence depends on prevalence and false positives. A negative test is evidence against disease, but a test with imperfect sensitivity can still miss true cases.

Posterior becomes the next prior. After one test, the updated probability becomes the starting point for the next test. Consecutive positive results can push the curve upward; consecutive negative results can push it downward.

High sensitivity and high specificity. When both are high, a positive result strongly pushes the probability upward, and a negative result strongly pushes it downward. In that setting, each test result carries a lot of information.

High sensitivity and low specificity. The test rarely misses true cases, but it also produces many false positives. A negative result can still be reassuring, while a positive result may need more confirmation, especially when the prevalence is low.

A bridge to Naive Bayes. Repeated updates are equivalent to multiplying conditional probabilities when the observations are treated as conditionally independent given the hidden state. That is the same simplification behind a Naive Bayes classifier. In this demo, the observations are repeated test results. In a classifier, the observations are features such as words, symptoms, or signals. The mathematical move is the same, and the next topic will make this independence assumption precise.