PDF
Bayes Theorem1Bayes' Theorem: Updating Beliefs with EvidenceContentsThe Problem of Inverse Probability ................................................................. 1Bayes Theorem ....................................................................................... 1The Odds Form ........................................................................................ 2Implementation ...................................................................................... 3Applications ........................................................................................... 4The Philosophy of Priors ............................................................................. 5Conclusion ............................................................................................ 6Bibliography .......................................................................................... 6Your ability to do good science depends on your ability to update your beliefs in the face of evidence.The Problem of Inverse Probabilityinverse probabilityBayes Theoremposteriorlikelihoodpriormarginal likelihoodA Simple Examplebase rate neglect The Odds Form2PrevalenceSensitivitySpecificityVisualizing the UpdateStageP(disease)OddsThe Odds Formlikelihood ratio Implementation3Implementationclass BayesUpdater: """Bayesian belief updater using the odds form.""" def __init__(self, prior: float): self.odds = prior / (1 - prior) self.history = [prior] def update(self, lr: float) -> float: """Update belief with a new likelihood ratio.""" self.odds *= lr p = self.odds / (1 + self.odds) self.history.append(p) return p @property def probability(self) -> float: return self.odds / (1 + self.odds)# Medical diagnosis examplebelief = BayesUpdater(prior=0.001)# First positive test (LR = sensitivity / (1 - specificity))belief.update(lr=0.99 / 0.05) # P 0.0194print(f"After 1st positive: {belief.probability:.4f}")# Second independent positive testbelief.update(lr=0.99 / 0.05) # P 0.284print(f"After 2nd positive: {belief.probability:.4f}")# Third independent positive test Applications4belief.update(lr=0.99 / 0.05) # P 0.867print(f"After 3rd positive: {belief.probability:.4f}")After 1st positive: 0.0194After 2nd positive: 0.2841After 3rd positive: 0.8673ApplicationsSpam FilteringA Plan for Spam The Philosophy of Priors5A/B TestingBayesian Neural NetworksdistributionThe Philosophy of PriorsallObjective BayesSubjective BayesEmpirical Bayes Bibliography6Conclusionwhat is the likelihood ratio, and what was my prior?BibliographyProbability Theory: The Logic of ScienceLarge-Scale Inference: Empirical Bayes Methods for Estimation, Testing, and Prediction

HTML view coming soon.

Download PDF for the full formatted version.