Beta-Binomial conjugate: Prior Beta(α,β) + k successes out of n observations → Posterior Beta(α+k, β+n−k).
The blue curve is the prior, purple is the posterior. The green dashes show the likelihood.
Bayesian inference is a method of statistical reasoning that updates a probability estimate — called the prior — as new evidence arrives, producing a posterior distribution. The update rule is Bayes' theorem: P(θ|data) ∝ P(data|θ) × P(θ), where θ is the unknown parameter, P(θ) is the prior belief, P(data|θ) is the likelihood of observing the data if θ were true, and P(θ|data) is the posterior. Unlike frequentist statistics, which treats parameters as fixed unknowns, Bayesian inference treats them as random variables with probability distributions that are sharpened by evidence.
This simulator uses the Beta-Binomial conjugate pair, ideal for estimating proportions. Set your prior belief via the α (prior successes) and β (prior failures) sliders, then click "Success" or "Failure" to add observations. Each click updates the posterior Beta(α+k, β+n−k) in real time — the blue prior curve shifts and narrows into the purple posterior as evidence accumulates. The Medical Test scenario pre-sets a Beta(1,9) prior, representing a 10% disease prevalence before testing.
What is the difference between a prior, likelihood, and posterior?
The prior P(θ) encodes your beliefs about the parameter θ before seeing any data — it might come from previous studies, expert knowledge, or a deliberately uninformative flat distribution. The likelihood P(data|θ) is how probable the observed data would be for each possible value of θ. The posterior P(θ|data) ∝ prior × likelihood is your updated belief after seeing the data; it balances prior knowledge and observed evidence according to their relative strength.
What is the Beta distribution and why is it used here?
The Beta distribution Beta(α,β) is defined on [0,1] and naturally represents uncertainty about a probability. Its mean is α/(α+β) and its mode (MAP estimate) is (α−1)/(α+β−2) for α,β > 1. It is the conjugate prior for the Binomial likelihood, meaning that if the prior is Beta(α,β) and you observe k successes out of n trials, the posterior is exactly Beta(α+k, β+n−k) — no numerical integration needed.
Why does adding more data narrow the posterior curve?
The posterior variance is αβ / ((α+β)²(α+β+1)). As k successes and (n−k) failures are added, α+β grows, reducing the variance — the distribution becomes more concentrated around the true proportion. With enough data the posterior becomes extremely narrow regardless of the prior, reflecting the principle that sufficiently large datasets can overcome even strongly mistaken prior beliefs.
MAP stands for Maximum A Posteriori — it is the value of θ that maximises the posterior density. For Beta(α,β) it equals (α−1)/(α+β−2) (for α,β > 1). With a uniform prior (α=β=1, equivalent to no prior knowledge), the MAP collapses to the maximum likelihood estimate k/n — just the observed proportion. The MAP is shown as a yellow dashed line on the chart.
The 95% credible interval (CI) contains 95% of the posterior probability — you can directly say "there is a 95% probability that θ lies in this interval." A frequentist 95% confidence interval has a subtler meaning: if the experiment were repeated many times, 95% of the computed intervals would contain the true fixed parameter. For large samples the two are numerically similar, but their interpretations differ fundamentally.
A conjugate prior is a prior distribution whose functional form is preserved after multiplying by the likelihood: the posterior has the same parametric family. For Binomial likelihood, the conjugate prior is Beta; for Poisson, it is Gamma; for Gaussian with known variance, it is another Gaussian. Conjugacy avoids numerical integration, giving a closed-form posterior update that is analytically exact and computationally instant.
The Medical Test preset sets α=1, β=9, representing a prior disease prevalence of ~10%. Each "Success" click represents a positive test result. If the test has 90% sensitivity and 95% specificity, a positive result should update the posterior substantially upward. This scenario illustrates the base-rate fallacy: even a highly accurate test applied to a rare disease produces many false positives, because the prior probability of disease is low — a key concept in medical screening policy.
Bayesian updating is the process of using today's posterior as tomorrow's prior. If you observe 3 heads from 5 flips, the posterior is Beta(1+3, 1+2) = Beta(4,3). If you then observe 2 more heads from 4 flips, you update to Beta(4+2, 3+2) = Beta(6,5). The final result is identical to computing the posterior from all 9 flips at once — sequential and batch Bayesian inference are provably equivalent, as long as observations are independent.
Use an uninformative (flat or weakly informative) prior when you have little prior knowledge and want the posterior to be dominated by data — Beta(1,1) in this simulator. Use an informative prior when you have genuine prior information (e.g., from a meta-analysis) that should influence conclusions even with small datasets. In clinical trials, regulators sometimes require pre-registration of priors to prevent posterior-fishing — choosing the prior after seeing the data to get a desired result.
The frequentist maximum-likelihood estimate (MLE) for a coin's heads probability is simply k/n — the observed proportion. A frequentist 95% confidence interval is approximately p̂ ± 1.96 × √(p̂(1−p̂)/n). The Bayesian posterior mean is (α+k)/(α+β+n), which equals the MLE only for a flat prior (α=β=1) with large n. For small samples, the Bayesian approach naturally regularises the estimate toward the prior, avoiding overfitting to sparse data.