bayes() — Bayes’ theorem

Updates how sure you are after you get a new clue.

P(A|B) = P(A)·P(B|A) / P(B)

Key idea

Definition

the POSTERIOR — your updated chance of A after seeing the evidence (what you want)
the PRIOR — your chance of A before any evidence (the base rate)
the likelihood — how likely the evidence is when A is true (how strong the clue is)
the EVIDENCE — the overall chance of seeing the clue either way (from the law of total probability)

In plain words

You think it might rain. Then you see dark clouds. Bayes helps you turn “maybe” into a better, updated chance of rain.

Where you'd use it

Worked example 4

Prior P(sick): a disease hits 1% of people. Evidence: a positive test, which is right 90% of the time on real cases (the likelihood) but cries wolf 8% of the time. Posterior P(sick | positive): combining them, the real chance you are sick is only about 10%.

Frequently asked questions

What is the key idea of Bayes?
Update a prior belief with evidence to get a posterior. Crucially, P(A|B) ≠ P(B|A).
Why are most positive tests wrong for a rare disease?
The base rate is tiny, so false positives outnumber the true ones.