Probability, Bayesian reasoning, and uncertainty / personal lessonsLesson 5 of 14
Probability · Lesson 5

Update a base rate with evidence

Bayes’ rule compares the routes that could have produced the observed result.

By the end: Calculate posterior probability using natural frequencies and distinguish sensitivity, specificity, and predictive value.

Count both routes to a positive result

Imagine 10,000 items, 1% faulty. A test flags 90% of faults and 5% of sound items. Of 100 faults, 90 are flagged. Of 9,900 sound items, 495 are flagged. Among the 585 positives, only 90 are faulty, about 15.38%. The test has increased the fault probability substantially, but a positive is not a near-certainty of fault.

The prior is the probability before this result, based on the chosen population and existing information. The likelihood is the probability of the observed result under a specified state. The posterior is the updated probability of the state after the result. Bayes’ rule multiplies prior by likelihood, then divides by the total probability of the result.

Separate the source groups before selecting positives

A positive result has two possible sources in this model. It can come from a faulty item that the test detects, or from a sound item that the test flags incorrectly. To compare those explanations, first keep the groups separate. Among 10,000 items with fault probability 1%, the expected faulty group has 100 items. The remaining 99%, or 9,900 items, form the sound group. Neither group size follows from the test result. These are the starting weights before testing.

Apply each conditional test rate only to its own group. Sensitivity of 90% means nine tenths of the faulty group test positive. That gives 90 expected true positives and ten expected false negatives. A false-positive rate of 5% applies to the sound group, not to everyone. Five hundredths of 9,900 gives 495 expected false positives. Subtracting these from 9,900 leaves 9,405 expected true negatives. The four groups add back to 10,000, so every starting item has exactly one destination.

Two sources feed the positive group

10,000 items1%99%Faulty100Sound9,90090%10%5%95%90 positive10 negative495 positive9,405 negative90 faulty + 495 sound = 585
Constructed expected frequencies. Branch lengths are schematic, not probability scales. Multiply conditional rates along a route; add the two positive endpoints to get 585.

Now suppose the only new information about an item is that it tested positive. The negative destinations no longer belong in the denominator. The positive group contains 90 plus 495, or 585 expected items. The faulty share is 90 divided by 585, about 15.38%. Another way to read the comparison is that sound positives outnumber faulty positives by 495 to 90, or 5.5 to one. A fairly small error fraction from a large source group can outweigh a large detected fraction from a small source group.

The likelihood of a positive under fault is 90%. That answers what the test tends to report if the item's state is already specified. The posterior fault probability after a positive is about 15.38%. That answers which state plausibly produced a report whose source is unknown. The likelihood does not include how common each source was beforehand. Reversing these questions would replace the positive denominator of 585 with the faulty denominator of 100, even though those groups answer different questions.

The total positive probability is 585 divided by 10,000, or 5.85%. The joint probability of fault and positive is 90 divided by 10,000, or 0.9%. Dividing 0.9% by 5.85% gives the same posterior as dividing the expected counts. The population size cancels. Using expected counts for 100,000 items would multiply both numerator and denominator by ten without changing their ratio. Natural frequencies make the source accounting visible; they do not add a new assumption to the conditional-probability identity.

These counts describe expectations under the specified rates. They are not a promise that the next batch contains exactly 100 faulty items or 585 positives. A realized evaluation table may differ because items and results vary. If a batch's true states and test results were fully counted, its observed fraction would be an empirical fraction for that batch. Here we use the rates to calculate a model probability for an unknown item. Comparing that prediction with later observations is a separate check of the model.

The same numerator answers different questions

QuestionCalculationMeaning
Positive given fault90 / 100 = 90%Sensitivity, a likelihood
Fault given positive90 / 585 ≈ 15.38%Posterior fault probability
Fault and positive90 / 10,000 = 0.9%Joint probability
Positive585 / 10,000 = 5.85%All positive routes
Every numerator and denominator comes from the same constructed model. Changing the denominator changes the question, not the underlying test result.

Performance and prevalence play different roles

Sensitivity is P(positive | fault). Specificity is P(negative | sound); the false-positive rate is one minus specificity. Positive predictive value is P(fault | positive). Changing prevalence while preserving the two conditional test rates changes predictive value.

Do not assume that test rates really stay fixed between populations. Different fault types, thresholds, measurement conditions, or case-selection methods can change them. The experiment below varies prevalence while holding performance fixed to isolate the arithmetic, not to predict an actual test.

Ask which population supplied the prior

A prior describes uncertainty before the particular result being used for an update. It need not mean before anyone has learned anything about the item. Consider a different constructed screening population with 4% faults. For 10,000 tested items, that means 400 expected faulty items and 9,600 sound items. Keep sensitivity at 90% and the false-positive rate at 5%. The two positive routes now contribute 360 faulty positives and 480 sound positives. The posterior is 360 divided by 840, or about 42.86%.

Compared with the 1% population, the faulty source became four times as large while the sound source became slightly smaller. The test's conditional rates did not improve. Nevertheless, a positive became much more likely to indicate fault. This is a change in the mixture being tested. It does not mean the test learned the base rate or adapted its threshold. A posterior belongs to a result together with a population and an information set, rather than to a positive symbol considered by itself.

Change the source mixture, preserve the test rates

Prior fault chanceFaulty positivesSound positivesFault given positive
1%100 × 0.9 = 909,900 × 0.05 = 49590 / 585 ≈ 15.38%
4%400 × 0.9 = 3609,600 × 0.05 = 480360 / 840 ≈ 42.86%
Both rows use 10,000 expected items, 90% sensitivity, and a 5% false-positive rate. The posterior changes because the source weights change.

Suppose the factory first selects items with unusual vibration, then tests only those items. The relevant prior for a tested item is the fault probability among items with that vibration pattern, not automatically the overall production rate. A representative study might establish that selected rate. Merely noticing vibration does not supply its numerical value. If 4% already describes the vibration-selected group, multiplying again by an evidence factor for the same vibration would count that information twice. New evidence must be new relative to the prior's information.

Keeping sensitivity and false-positive rate fixed across these populations is also an assumption. Vibration-selected faults might be easier for the detector to find. Sound items with vibration might confuse it more often. Then both source weights and conditional rates change. Before transferring a detector specification, ask whether the fault categories, measurement procedure, and selection criteria match. An evaluation containing only severe faults can estimate sensitivity for those severe faults while giving an unhelpful estimate for subtle faults in the production population.

A useful sensitivity calculation changes one uncertain input at a time. At the original 1% prior, suppose sensitivity were 80% instead of 90%, with the same 5% false-positive rate. Expected faulty positives fall from 90 to 80; sound positives remain 495. The posterior becomes 80 divided by 575, about 13.91%. That calculation isolates uncertainty about sensitivity. Changing several inputs together may also be reasonable, but the resulting difference cannot be attributed to prevalence alone or to detector quality alone.

None of these comparisons establishes that a fault causes the detector's response through a particular physical mechanism. They specify conditional probabilities sufficient for prediction under a model. Random sampling can help estimate such rates for a target population. Random assignment of a repair or another intervention would address what that intervention changes. Selecting likely faults for measurement is neither of those operations by itself. Keep evidence about the source population separate from evidence that an action prevents damage, even when the same factory collects both datasets.

Different evidence supports different inputs

Input or claimRelevant evidenceNot established by
Prior for vibration-selected itemsFault fraction in a relevant selected populationOverall factory rate alone
Sensitivity after selectionResults for relevant faulty itemsSevere-fault examples alone
False-positive rate after selectionResults for relevant sound itemsSensitivity alone
Repair prevents damageA credible causal comparison of repair outcomesFault and positive association alone
Sampling a population and assigning an intervention answer different questions. The evidence must match the input being estimated.

Work through the mechanism

1. Count both positive branches
90+495=585

Of 10,000 items: 100 faulty times 0.9, plus 9,900 sound times 0.05.

2. Normalize within the positive group
Posterior=90585≈0.1538

The posterior is the fraction of positive results that came from faulty items.

3. General form of Bayes’ rule
P(H | E)=P(E | H)×P(H)P(E)

H is the hypothesized state; E is observed evidence. The denominator sums every route to E and must be positive.

Restrict the denominator to positive results

All 10,000 items: 1% faultyPositive group only: 15.38% faultyBlue: faulty. Gold: sound. Each entire bar represents 100%.
StatePositiveNegative
Faulty9010
Sound4959,405

Fault among positives: 90 / 585 ≈ 15.38%.

Sensitivity 90%; false-positive rate 5%. The second bar rescales the positive column, not the full population. Counts are model expectations. Presets and slider replace prevalence immediately; no measurement is collected.
Actual statePositiveNegative
Faulty9010
Sound4959,405
At 1% prevalence, the positive column contains 585 items. Every number follows from the stated rates.

Use the prevalence control to trace both branches

In the screening experiment, begin with the Rare faults preset. Before reading the posterior, identify the two rows of its table. The faulty row divides into 90 positives and ten negatives. The sound row divides into 495 positives and 9,405 negatives. The upper strip shows the faulty share among all items. The lower strip shows that share after retaining only positives. Each full strip represents its own whole population, so equal lengths do not mean equal numbers of items.

Choose High prevalence next. At 20%, the same 10,000-item reference population has 2,000 expected faults and 8,000 sound items. Sensitivity gives 1,800 faulty positives; the false-positive rate gives 400 sound positives. The positive denominator is now 2,200, and its faulty share is 1,800 divided by 2,200, about 81.82%. The upper strip still has a much smaller faulty fraction than the lower strip. A positive raises fault probability in both populations, though neither the increase in percentage points nor the final posterior is fixed.

Use the slider to set prevalence to 5%, a case between the named presets. Predict the row totals first. Five hundred items are faulty and 9,500 are sound in expectation. Their positive branches give 450 and 475 respectively. A positive therefore has fault probability 450 divided by 925, about 48.65%. The two positive sources are almost equally numerous, despite the test flagging faulty items eighteen times as often as sound ones. The nineteen-to-one initial sound majority almost offsets that difference.

Ask where the two positive sources would balance exactly. For every faulty item, the positive contribution is 0.9; for every sound item, it is 0.05. Equal contributions require eighteen sound items for every faulty item. That is one faulty item among nineteen total, or about 5.263% prevalence. The slider takes whole percentage steps, so it cannot select this exact balancing point. The 5% setting falls below it, and 6% falls above it. This is a paper comparison, not an additional control.

Equal positive contributions need unequal source groups

Faulty source: 1 itemSound source: 18 items1 × 90% = 0.918 × 5% = 0.9Prior: 1 / 19 ≈ 5.263%Positive posterior: 50%Slider 5%: below balanceSlider 6%: above balance
At prior fault probability 1/19, the two positive sources balance. Each circle represents one source item. The 18 sound items together contribute 18 × 0.05 = 0.9 expected positives, equal to 1 × 0.9 from the faulty item. Circles show source counts, not guaranteed outcomes.

The positive result itself occurs more often as prevalence rises. The positive fraction is 5% of the population plus an extra 85 percentage points times the faulty fraction. This expression comes from a 5% flag chance for sound items and a 90% chance for faulty ones. At 5% prevalence it gives 9.25% positives; at 20% it gives 22%. Thus a larger posterior and a larger positive group can occur together. A posterior alone does not tell the operator how many items will need follow-up.

The experiment changes prevalence immediately and preserves both test rates. It does not generate batches, estimate uncertainty, or let you alter detector sensitivity. To investigate those questions on paper, change the relevant branch assumptions and rebuild the totals. Read the table as expected frequencies, and use the strips to compare proportions. If their apparent agreement persuades you that the detector rates are empirically reliable, you have inferred more than the display establishes. Both representations calculate consequences of the same supplied inputs.

Follow-up volume and predictive value have different denominators

Fault prevalenceExpected positives per 10,000Positive share of everyoneFault share of positives
5%450 + 475 = 9259.25%450/925 ≈ 48.65%
20%1,800 + 400 = 2,20022%1,800/2,200 ≈ 81.82%
Sensitivity remains 90% and the false-positive rate remains 5%. Expected follow-up volume counts both positive branches. Predictive value uses the positive group as its denominator. Neither percentage measures the causal benefit of following up.

Priors need reasons and sensitivity checks

A relevant base rate is often a useful prior, but reference classes matter. A random item from a production line and an item already emitting smoke need not start at the same fault probability. Do not count the smoke once in the prior and again as new evidence.

A probability forecast is calibrated if, across comparable cases assigned a given probability, the event occurs at that rate. A constant base-rate forecast can be calibrated yet fail to identify which individual cases are faulty. Calibration and the ability to separate cases are different properties. Report how conclusions change across plausible priors and likelihoods. Bayes’ rule is an identity inside a probability model; it cannot repair irrelevant data, a missing explanation, or a likelihood chosen to favor a conclusion. The examples are invented screening problems, not medical advice or measured detector specifications.

Judge probability forecasts separately from actions

A fault probability can be evaluated across cases even when each item's state is fixed. Suppose a forecasting rule assigns 20% to each of 1,000 comparable items. If about 200 turn out faulty, the observed proportion agrees with that forecast at this probability level. Calibration asks whether event frequencies match assigned probabilities across relevant groups of cases. One matching batch does not establish lasting calibration. Production changes can break agreement, and small groups permit substantial random variation.

Now construct two forecasting rules for a population containing 200 faulty and 800 sound items. Rule A assigns 20% to everyone. Rule B assigns 10% to 800 items, including 80 faults, and 60% to 200 items, including 120 faults. Both rules have exact groupwise agreement in this invented dataset. Rule B nevertheless separates a higher-risk group from a lower-risk group. The higher group contains 60% of all faults while containing only 20% of all items. Calibration alone would not distinguish these rules' ability to prioritize inspection.

Separation alone does not establish calibration either. If Rule B instead reports 90% for its higher group and 40% for its lower group, its ranking stays unchanged. The same items still receive priority, but both numerical probabilities overstate the observed faulty shares. A decision rule that uses an actual probability threshold may then take different actions. Ranking answers which cases look riskier; calibration answers whether the numerical levels match frequencies. Both questions require evaluation on cases not chosen merely because they made the rule look good.

Both forecasts agree with their group frequencies

Rule A: 20% for everyoneRule B: two risk groups200 faulty / 1,000 = 20%Upper: 80 / 800 = 10%Lower: 120 / 200 = 60%Blue = faulty; gold = soundOne dot = 10 items
Constructed outcomes, not evaluation data. Each dot represents ten items; blue dots are faulty and gold dots are sound. Rule A predicts 20% for all 1,000. Rule B predicts 10% for 800 and 60% for 200. Both agree with these group frequencies; only B identifies a higher-risk group.

After a Bayesian update, choosing an action still requires consequences. Imagine an action that prevents all modeled fault loss, costs two units on a sound item, and costs zero on a faulty item. Waiting loses eight units on a faulty item and zero on a sound item. At a 15.38% posterior, acting has expected loss about 1.69 units, while waiting has expected loss about 1.23. Waiting is better under these assumptions even though the positive result increased risk substantially. The posterior is an input to this comparison, not the action itself.

Change only the missed-fault loss from eight to twenty. Expected waiting loss at the same posterior becomes about 3.08 units, while acting stays near 1.69. The preferred action reverses without any new evidence about fault. These examples use stipulated losses and perfect prevention to expose the distinction. Real claims that acting prevents damage need causal evidence. An association between a positive result and subsequent damage cannot tell us how much damage a repair would prevent, what new harms it causes, or whom those harms affect.

The conditional arithmetic may be correct while the prevalence estimate describes the wrong production line. A detector may rank cases well while overstating their risks. A calibrated posterior may still feed an inappropriate loss table. Identify which claim each new observation supports before revising the calculation. More screening data can improve estimates of the test's predictive behavior; they do not automatically establish the effects of intervention or settle the value assigned to a missed fault.

The same posterior can support different actions

Loss assumptionsAct expected lossWait expected lossLower loss
Sound action costs 2; missed fault costs 822 / 13 ≈ 1.6916 / 13 ≈ 1.23Wait
Sound action costs 2; missed fault costs 2022 / 13 ≈ 1.6940 / 13 ≈ 3.08Act
Both rows use posterior fault probability 90/585 = 2/13 and zero loss for correct actions. These are stipulated consequences with perfect prevention, not measured intervention effects. Only the loss assumptions change.

Exercises

A less rare fault

Keep sensitivity 90% and false-positive rate 5%, but use 10% prevalence. What fraction of positives are faulty?

Hint

Use a population of 10,000 again.

Worked answer
Probability, fixed 0–100% scalePrior10%Posterior66.67%
Positive sourceCount
Faulty900
Sound450
Fault fraction among positives900/1,350 = 66.67%
Compare with 90/585 in the baseline population.

There are 1,000 faulty items, producing 900 positives. The 9,000 sound items produce 450 positives. The posterior is 900/1,350 = 2/3, about 66.67%. The detector’s conditional rates did not change; the mixture of tested items did.

Improve specificity

At 1% prevalence and 90% sensitivity, lower the false-positive rate to 1%. Find the posterior after a positive.

Hint

There are still 9,900 sound items.

Worked answer
Probability, fixed 0–100% scaleBefore improvement15.38%After improvement47.62%
Positive sourceBeforeAfter
Faulty9090
Sound49599
Fault fraction15.38%47.62%
Specificity rises from 95% to 99%; sensitivity stays fixed.

True positives remain 90, while false positives fall to 99. The posterior is 90/189 = 10/21, about 47.62%. A large improvement still does not make every positive genuine because the sound population is much larger.

Sources and further reading

The explanations and exercises are complete without these optional links. The references distinguish probability identities from inference procedures and reporting guidance. The examples are constructed teaching models, not empirical estimates or professional decision advice.