Bayes' theorem updates a belief about a cause after observing an effect. It combines a prior probability with a likelihood, then normalizes the resulting joint probability to obtain a posterior probability. section 13.0 section 13.3
Written for events A and B, P(A|B) = P(A)P(B|A) / P(B) = P(A&B) / P(B). The theorem reverses the direction of reasoning: evidence about an effect updates confidence in its possible cause. section 13.1 section 13.3
Sneezing and colds
A survey of 10,000 people finds 1,000 with colds, establishing a 10% prior probability. Among 1,000 people with colds, 860 sneezed, giving an 86% likelihood of sneezing given a cold. Reversing the question, 860 of the 1,130 people who sneezed had colds, so the posterior probability is 860/1,130. section 13.1
A generic implementation represents the prior as IDiscreteDistribution<A> and the likelihood as Func<A, IDiscreteDistribution<B>>. It forms a joint distribution, filters it to the observed evidence, and projects the remaining causes into the posterior. section 13.3
Computing the posterior in C#
With a prior assigning weights 90 and 10 to no cold and cold, Posterior(SneezedGivenCold) produces the observed-sneeze weights No:27 and Yes:86, matching the survey ratio 270:860.
