Learning LabExplorable explanations
← All artifacts
Statistics

Bayesian vs Frequentist

One coin, one question: what is its bias? Answer it two ways on the same flips, a confidence interval that earns its 95% over repeated samples and a Bayesian posterior that says how probable each bias is.

bayesianfrequentistconfidence-intervalcredible-interval
LiveInteractive · drag, toggle, run it
Statistics · Two Philosophies of Inference

Bayesian vs Frequentist

A coin has some unknown bias p toward heads. You flip it and watch two schools answer the same question from the same data. The frequentist treats p as one fixed number and reports an interval whose 95% is a property of the procedure. The Bayesian treats p as uncertain, carries a distribution, and reports an interval you can read as a direct probability. Change the hidden bias, add flips, and watch the two intervals tell their different stories about the same data.

The coin and your data
p = 0.70
Flip the coin
Heads
0
Tails
0
Flips n
0

Same data, both intervals on one axis

p axis: 0 (always tails) to 1 (always heads)

The curve is the Bayesian posterior density over p. The dashed curve is the prior you started from. The shaded band under the curve is the 95% credible interval. The flat bar just below the axis is the frequentist 95% interval. The green dashed line is the true p; the solid blue line is the point estimate p̂ = heads / n.

00.250.50.751
posterior densityprior (dashed)95% confidence interval95% credible intervaltrue p
No flips yet, so the posterior is just the prior and the frequentist interval is undefined. Flip the coin to begin.
Frequentist

p is fixed, the interval is random

MLE p-hat
95% Wilson CI

The bias p is one fixed unknown constant; it has no probability distribution. Probability lives in the long-run frequency of the procedure. The 95% confidence interval is a recipe: if you repeated the whole experiment forever, about 95% of the intervals it produces would cover the true p. Wilson inverts the score test and keeps coverage near nominal even at small n, which is why it is preferred.

Bayesian

p is uncertain, described by a distribution

Posterior mean
0.500
MAP (mode)
95% credible interval
[0.025, 0.975]
Posterior
Beta(1, 1)
flat: every bias equally plausible before data

Start with a Beta(α, β) prior. Because the Beta is conjugate to the binomial likelihood, the update is exact and free: heads add to α, tails add to β, giving the posterior Beta(α+0, β+0). The 95% credible interval holds 95% of the posterior probability, so here you may say plainly: given this prior and this data, there is a 95% probability that p lies inside it.

What 95% confidence actually means

Repeated sampling, the honest demonstration

Fix the true p, then draw many fresh independent experiments of size n = 20 and build a 95% interval for each. The confidence statement is not about any single interval; it is about this stack. Roughly 95% of the intervals should cover the true p (the green line). The ones in red miss it. That coverage is the entire content of the word confidence.

each draws n = 20 flips at true p = 0.70
Run the simulation to watch coverage approach 95%.
Confidence level
95%Both intervals widen together as you raise the level. Wider intervals are the price of being more often right.
The punchline: two answers, two meanings

They often nearly coincide. With a flat Beta(1,1) prior and plenty of data, the Bayesian credible interval and the frequentist Wilson interval land almost on top of each other. The numbers agree because the likelihood dominates and the prior has washed out.

They diverge with small n or a strong prior. Early on, or under the believes-fair Beta(20,20) prior, the posterior is pulled toward 0.5 and its interval separates from the frequentist one. Add flips and watch the prior's pull fade as the data takes over.

They never mean the same thing. The credible interval is a statement about p given your data:95% of the posterior probability sits inside it. The confidence interval is a statement about the procedure: over endless repeated samples, 95% of the intervals it builds would cover the fixed true p. You cannot say a single confidence interval has a 95% chance of containing p, that probability is already either 0 or 1, you just do not know which.

Seeded mulberry32 draws · conjugate Beta-Binomial update · Wilson and Wald intervals · incomplete-beta quantiles