L1Reviewed 2026-07-19

Uncertainty and Bayesian thinking

How probability helps machines (and people) update beliefs when the world is noisy.

What you'll learn

  • State Bayes' rule in plain language: prior, likelihood, posterior.
  • Run a simple numeric belief update with evidence.
  • Connect probability to ML loss, calibration, and /learn/hallucinations.

Plain English

The world rarely gives perfect information. Sensors glitch, labels lie, and models guess. Probability is the math of 'how sure are we?'—and Bayes' rule is the recipe for changing your mind when new evidence arrives.

You start with a prior belief (maybe 1% chance of rain). You see dark clouds—a likelihood that fits rain more than sun. The posterior is your updated belief. Machines use the same pattern for spam filters, medical tests, and robot localization.

Language models output scores that look like confidence but are not always calibrated probabilities. Bayesian thinking still helps you design evaluations (/learn/benchmarks-and-evaluation) and spot overconfident wrong answers (/learn/hallucinations).

How it works

Bayes' rule: P(H|e) = P(e|H) P(H) / P(e). Read it as: posterior equals likelihood times prior, normalized. For multiple hypotheses, compute each posterior and pick the argmax (MAP) or keep the full distribution if decisions need risk awareness.

Bayesian networks compactly represent joint distributions with conditional independence. Hidden Markov models handle sequences (speech, biology). Markov decision processes add actions and rewards—CS188's bridge from probability to planning and /learn/reinforcement-learning.

In supervised learning, cross-entropy loss relates to maximum likelihood: choose parameters that make observed labels probable. Regularization acts like a prior favoring simpler models (/learn/overfitting-and-generalization).

Toy Bayesian update — is the coin fair or biased?
python
# Two hypotheses: fair coin (50% heads) vs biased (80% heads)
prior_fair = 0.9
prior_biased = 0.1

# After observing 7 heads in 10 flips, likelihood ~ Binomial
def binomial_likelihood(p, heads, flips):
    from math import comb
    return comb(flips, heads) * (p ** heads) * ((1 - p) ** (flips - heads))

heads, flips = 7, 10
like_fair = binomial_likelihood(0.5, heads, flips)
like_biased = binomial_likelihood(0.8, heads, flips)

# Bayes: unnormalized posterior ∝ likelihood × prior
post_fair = like_fair * prior_fair
post_biased = like_biased * prior_biased
total = post_fair + post_biased

print("P(fair | data) =", round(post_fair / total, 3))
print("P(biased | data) =", round(post_biased / total, 3))

Going deeper

Exact inference grows hard in large networks; Monte Carlo sampling and variational methods approximate posteriors. Deep learning often sidesteps explicit Bayes but borrows ideas in dropout-as-approximate-Bayes debates and uncertainty quantification research.

Decision theory combines probabilities with utilities: act to minimize expected loss. For AI safety, explicit uncertainty prompts humility—report 'I don't know' when evidence is thin (/learn/alignment-and-safety). CS188 probability chapters ground these ideas before neural hype.

Common misconceptions

Bayes' rule eliminates all uncertainty.
It updates beliefs; posterior spread can remain wide when data is scarce or noisy.
Softmax outputs from neural nets are true probabilities.
They are scores that may be miscalibrated unless trained and tested for calibration on the deployment task.
Prior choices never matter with enough data.
With small or biased samples, priors and data collection dominate outcomes—see /learn/data-and-labels.

Key facts

  • Bayes' rule updates P(hypothesis|evidence) using prior and likelihood.
  • MAP picks the most probable hypothesis; full posteriors support risk-sensitive decisions.
  • Bayesian networks factor complex joint distributions.
  • Maximum likelihood training in ML aligns with probabilistic modeling.
  • Calibration checks whether stated confidence matches empirical accuracy.

Sources used

These free resources informed this page. ANN writes original explainers; we do not copy course text behind paywalls.

Also explore AI companies, Live Feed, and Weekly Brief.