Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
Bayes' theorem is the single most important formula in applied probability. It tells you how to invert a conditional — from , which you usually have, to , which you usually want. Every modern ML model that does inference is using a Bayes update somewhere. The infamous failure mode is base-rate neglect: you read 'this test is 99% accurate' and conclude that a positive result means 99% chance of disease, when the actual posterior can be under 10% if the disease is rare. One worked Bayes calculation immunises you for life.
Bayes' theorem rewrites the conditional in the other direction by combining the prior , the likelihood , and the marginal evidence — typically computed via the law of total probability. The posterior is proportional to prior times likelihood.
// main.go — run: go run main.go
package main
import "fmt"
func main() {
// Classic medical-test problem.
// Prior: 1% of population has the disease.
// Test: 99% sensitivity (P(+ | D)), 95% specificity (P(- | not D) = 0.95, so P(+ | not D) = 0.05).
pD := 0.01
pPosD := 0.99
pPosNotD := 0.05
pPos := pPosD*pD + pPosNotD*(1-pD)
pDGivenPos := pPosD * pD / pPos
fmt.Printf("P(positive) = %.4f\n", pPos)
fmt.Printf("P(disease | +) = %.4f\n", pDGivenPos) // ~ 0.167
fmt.Printf("P(no disease | +) = %.4f\n", 1-pDGivenPos)
}go run main.go