Bayesian Updating

Prior → Likelihood → Posterior — the Beta-Binomial conjugate model

Flips n =0
Heads k =0
Post. mode =-
Post. mean =-
95% CI =-
1
1
0.60
med

What It Demonstrates

Bayes' theorem tells us how to update beliefs when new evidence arrives. For a coin with unknown bias p, the Beta distribution Beta(α, β) is a natural prior — it lives on [0, 1] and encodes pseudocounts of (H, T) outcomes. After observing k heads in n flips, the conjugate update is exact:

Prior Beta(α, β) + k heads, n−k tails → Posterior Beta(α+k, β+n−k)

No integration, no approximation — only two numbers change. This conjugacy is why the Beta-Binomial model is the textbook workhorse for proportion inference.

The simulation shows three curves: prior (your initial belief), posterior (updated belief after flips), and a vertical marker for the true p you set.

How to Use

Did You Know?

Bayesian updating is at the heart of spam filters, medical testing (PPV vs NPV), GPS receivers, and modern machine learning. The 95% credible interval shown here has a clean interpretation: "There is a 95% probability (given the data and prior) that p lies within this range" — unlike a frequentist confidence interval, which keeps the parameter fixed and varies hypothetical samples.

About Bayesian Updating

This simulation models the Beta-Binomial conjugate update — the mathematical engine behind Bayesian inference for proportion estimation. You begin with a prior belief about a coin's bias, encoded as a Beta(alpha, beta) distribution, then flip the coin repeatedly; each observation shifts the prior into a tighter posterior via the exact rule Beta(alpha + k, beta + n - k), where k is heads and n is total flips. As evidence accumulates, the posterior narrows and converges toward the true hidden bias p you set on the slider.

Bayesian updating powers real-world systems from email spam filters and medical diagnostic testing to GPS signal fusion and adaptive recommendation engines. The framework dates to Thomas Bayes' posthumous 1763 paper and was independently developed by Pierre-Simon Laplace.

Frequently Asked Questions

What is Bayesian updating?

Bayesian updating is the process of revising a probability estimate (the prior) in light of new evidence to produce an updated estimate (the posterior), using Bayes' theorem: P(H|E) = P(E|H) * P(H) / P(E). The prior encodes everything you believed before observing data, the likelihood measures how probable the observed data is under each hypothesis, and the posterior combines both. Crucially, today's posterior becomes tomorrow's prior as more data arrives.

How do I use the simulation controls?

Set the Prior alpha and beta sliders to define your starting belief: alpha = beta = 1 gives a flat (Uniform) prior that treats all biases equally likely, while larger alpha relative to beta encodes a belief that the coin favors heads. Set True p to the coin's actual hidden bias, then click Flip 1, Flip 5, Flip 20, or Flip 100 to accumulate observations. Toggle Auto-flip to watch the posterior evolve in real time, and hit Reset to clear flips while keeping the prior settings.

What does the 95% credible interval mean?

The 95% credible interval shown at the bottom of the chart means there is a 95% probability — given the observed data and the prior — that the true coin bias p falls within that range. This is a direct probability statement about the parameter, which is the Bayesian interpretation. It is distinct from a frequentist 95% confidence interval, which means that if you repeated the experiment many times, 95% of the constructed intervals would contain the true value — a statement about the procedure, not about a specific interval.

Why does the Beta distribution make a natural prior for coin bias?

The Beta distribution is defined on the interval [0, 1], exactly the range of a probability, and its two shape parameters alpha and beta can be interpreted as pseudocounts of prior heads and tails. Most importantly, it is the conjugate prior for the Binomial likelihood: multiplying a Beta prior by a Binomial likelihood yields another Beta distribution. This conjugacy means the posterior update requires only two additions (alpha += k, beta += n - k) rather than a numerical integral, making computation exact and instant regardless of how many flips have been observed.

Where is Bayesian updating used in the real world?

Spam filters use Bayesian updating to estimate the probability that a word (such as "free" or "winner") indicates spam, refining estimates as the user marks emails. Medical testing uses it to compute positive predictive value — the probability a positive test result means disease — by combining test sensitivity with the disease's prevalence prior. In GPS receivers, a Kalman filter applies sequential Bayesian updates to fuse noisy satellite signals with motion-model predictions. A/B testing platforms use Bayesian methods to estimate conversion rate posteriors and report credible intervals rather than p-values.

What is a common misconception about Bayesian vs. frequentist statistics?

A common misconception is that Bayesian methods are "subjective" and therefore less rigorous than frequentist methods. In practice, both approaches require modeling choices — frequentists choose a test statistic and significance level, Bayesians choose a prior. When the prior is weakly informative or there is abundant data, the posterior is dominated by the likelihood and converges to the same answer a frequentist would obtain. The real difference is interpretational: Bayesians assign probabilities to hypotheses, which aligns naturally with decision-making; frequentists define probability as long-run frequency, which avoids prior specification but makes direct probability statements about parameters impossible.

Who discovered Bayesian inference and when?

The Reverend Thomas Bayes (c. 1701-1761) derived the core theorem but never published it; his friend Richard Price found the manuscript and submitted it to the Royal Society, where it appeared in Philosophical Transactions in 1763, two years after Bayes' death. Pierre-Simon Laplace independently rediscovered and greatly extended the approach around 1774, giving it the mathematical form we use today and applying it to problems ranging from birth rates to celestial mechanics. The modern term "Bayesian statistics" only became common in the 1950s-1960s, championed by statisticians such as Harold Jeffreys, Leonard Savage, and Dennis Lindley.

What other simulations are related to Bayesian updating?

Bayesian Inference (Prior, Likelihood and Posterior) on this site extends the same framework to non-conjugate models. The Normal Distribution simulator demonstrates the Central Limit Theorem, which explains why posteriors from large samples become approximately Gaussian regardless of the prior. The Monte Carlo Pi simulator illustrates another probabilistic reasoning method — using random sampling to estimate quantities rather than closed-form posteriors. The Probability Distributions Explorer lets you inspect the Beta, Binomial, and other families that underpin conjugate models.

How is Bayesian updating used in machine learning and AI?

Naive Bayes classifiers apply Bayes' theorem to text and document classification, treating each word as independent evidence. Bayesian neural networks place distributions over network weights rather than point estimates, enabling uncertainty quantification in predictions. Gaussian Processes — used in Bayesian optimization for hyperparameter tuning — maintain a posterior distribution over entire functions and update it with each new experiment. Reinforcement learning algorithms such as Thompson Sampling use posterior samples to balance exploration and exploitation in multi-armed bandit problems, outperforming deterministic epsilon-greedy strategies on problems with limited data.

What is the frontier of Bayesian research today?

Scalable approximate inference is a major active area: methods such as Variational Inference (optimizing a simpler distribution to approximate the posterior) and Markov Chain Monte Carlo variants like No-U-Turn Sampler (NUTS, used in Stan and PyMC) make Bayesian updating tractable for models with millions of parameters. Bayesian deep learning research seeks to give neural networks calibrated uncertainty estimates without prohibitive computational cost. Another frontier is prior elicitation — systematically translating domain expert knowledge into prior distributions — and prior predictive checking, which evaluates whether a chosen prior generates plausible data before any observations are collected.