The Lawfare Academy

Lawfare Group → Knowledge Institute → Lawfare Academy

← CS 230 — Mathematics, Statistics and Data for AI

Weeks 6–8

Probability, conditional reasoning and base rates

Learning objectives

  • Explain and trace the mechanisms in probability, conditional reasoning and base rates.
  • Apply the method to the worked example and changed-condition exercise.
  • Identify assumptions, failure cases and the evidence needed to justify a result.

A probability describes uncertainty within a model or repeated sampling process. Conditional probability changes the reference group: P(alert given defect) is not P(defect given alert). Confusing them can produce badly overstated confidence when defects are rare. Begin with counts in a hypothetical population so every denominator is visible.

Suppose 100 of 10000 orders are defective. A detector flags 90 of those and also flags 495 of the 9900 nondefective orders. Sensitivity is 90/100 = 90 percent, while positive predictive value is 90/585, approximately 15.38 percent. Both statements can be true. The base rate and false-positive rate explain why most alerts are false despite high sensitivity.

Independence is an assumption about joint behavior, not a synonym for distinct events. Repeated alerts from closely related measurements may add less information than independent evidence. Expected value combines outcomes weighted by probabilities, but does not describe the full distribution or justify ignoring rare severe failures. When a model produces probabilities, assess calibration as well as ranking: among items assigned about 0.8 probability, the observed event rate should be near 0.8 under an appropriate evaluation setting.

Worked reasoning The denominator contains every flagged order, not every truly defective order. Calling 90 percent the chance that an alert is correct swaps the conditioning direction. If the deployment defect rate changes, predictive value can change even if conditional detection rates remain stable. That is why a laboratory result cannot be moved unchanged into any population.

Extended teaching and laboratory

Conditional probabilities reverse only with additional information. Sensitivity P(alert|defect) differs from predictive value P(defect|alert). A natural-frequency table makes the denominator visible. Count true alerts and false alerts in the same population before computing what an alert means.

Changing prevalence changes predictive value even if sensitivity and false-positive rate stay fixed. That is a mathematical consequence, not evidence that the test’s internal mechanism necessarily changed. Separate population shift from a changed conditional performance rate.

Worked problem Among 10,000 jobs, 1% are defective. A screen detects 90% of defects and alerts on 5% of nondefective jobs. Calculate the probability that an alert is a defect.

Step-by-step reasoning 1. There are 100 defective and 9900 nondefective jobs. The screen yields 90 true alerts and 495 false alerts.

  1. All alerts total 585. The predictive value is 90/585≈15.38%, not 90%.
  1. The 90% figure uses defective jobs as its denominator; the requested probability uses alerts.
  1. A negative result is another conditional question with a different denominator. Do not obtain it by subtracting the positive predictive value from one.

Apply the idea

Among 10,000 jobs, 1% are defective. A screen detects 90% of defects and alerts on 5% of nondefective jobs. Calculate the probability that an alert is a defect.

Prevalence rises to 10% in another 10,000-job population while both conditional alert rates stay the same. Recompute positive predictive value.

Read the worked reasoning

There are 1000 defective jobs, giving 900 true alerts, and 9000 nondefective jobs, giving 450 false alerts. Predictive value is 900/1350=66.67%. The alert becomes more informative in this population despite unchanged sensitivity and false-positive rate. Transporting the earlier 15.38% without checking prevalence would answer the wrong setting.

Check understanding

Why can high sensitivity coexist with low alert precision?

  1. Rare events plus many false alerts among the large negative group
    Feedback

    Conditioning and prevalence determine different denominators.

  2. Sensitivity and precision are always equal
    Feedback

    The metrics measure different properties.

  3. The number of negative cases never matters
    Feedback

    The large negative group can dominate alert counts.

Further reading

Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Study Dive into Deep Learning: Probability and Statistics; CS50 AI Uncertainty is an optional extension. Build contingency tables before manipulating conditional formulas.

My learning →