Probability: reasoning under uncertainty
Real agents rarely know things for certain. Probability lets them reason about how likely things are and update their beliefs when evidence arrives.
The basics
- P(A) is the probability of event A, between 0 and 1.
- Joint probability P(A, B): both happen.
- Conditional probability P(A | B): A happens given that B happened. P(A | B) = P(A, B) / P(B).
- Independence: A and B are independent if knowing B tells you nothing about A.
Bayes' rule
Bayes' rule flips a conditional probability around:
P(cause | evidence) = P(evidence | cause) × P(cause) / P(evidence)
Worked example. A disease affects 1% of people. A test catches 90% of real cases but also gives a false positive for 5% of healthy people. You test positive. How likely is it you have the disease?
- Out of 10,000 people, 100 have it; the test flags 90 of them.
- 9,900 don't have it; the test wrongly flags 5% of them, about 495.
- Positives in total: 90 + 495 = 585. True positives: 90.
- P(disease | positive) = 90 / 585 ≈ 15%.
Most people guess 90%. The rarity of the disease (the prior) matters enormously. This exact reasoning underlies spam filters, medical decision support and fraud detection, and it explains why rare-event detectors raise many false alarms.
Bayesian networks
A Bayesian network is a diagram of variables (nodes) connected by arrows showing which ones directly influence others, each with a table of conditional probabilities. Example: rain → train delay → missing an appointment. Given some evidence (the train was delayed), the network computes updated probabilities for everything else. When exact calculation is too slow, sampling methods simulate many random scenarios and count outcomes.
Reasoning over time
- A Markov chain models a sequence where the next state depends only on the current one (tomorrow's weather depends on today's).
- A hidden Markov model adds hidden states you can't observe directly but infer from observations (inferring the weather from whether people carry umbrellas). These powered speech recognition for decades.
Modern machine learning is deeply probabilistic: a classifier outputs probabilities, and a language model is, at its core, a probability distribution over the next word.
Check your understanding
A fraud detector is 95% accurate, but only 1 in 1,000 transactions is fraud. Most flagged transactions are likely to be:
In a Markov chain, the next state depends on: