Rosetta Stone · 23 of 30
Conditional probability
Notation: structural shorthand
In plain English
"The probability of A, given that B is true." The bar means given. You shrink the world to only the cases where B holds, then ask how often A occurs within them. and are generally different. Confusing them (“the prosecutor’s fallacy”) is one of the most common errors in reading evidence. Bayes’ rule converts one into the other.
As code
// P(A|B) = count(A and B) / count(B)
const rows = data.filter((r) => r.B);
const pAgivenB = rows.filter((r) => r.A).length / rows.length;Where the analogy bends: Counting works with data. In models, conditional probabilities are computed (e.g. a language model outputs P(next token | context)).
See it
What it means, field by field
P(A|B) = P(A ∩ B) / P(B); the basis of Bayes’ theorem.
Language models output P(next token | previous tokens); classifiers output P(label | input).
P(disease | positive test); P(phenotype | genotype); inheritance probabilities.
P(data | hypothesis) is not P(hypothesis | data). p-values are the former.
In a research paper
Belief in hypothesis H after seeing evidence E = how well H predicted E, times prior belief in H, normalised.
Common misreadings
Swapping the conditional: treating P(positive | disease) as P(disease | positive).
Reading the bar as division or as "or".
Reading a p-value as the probability that the hypothesis is false.