Posterior Calculator
Bayesian analysis asks what you should believe after seeing data, given what you believed before. For a handful of famous prior-and-data pairings the answer needs no simulation at all: the posterior falls out of a formula, and the update is just arithmetic on the prior's parameters. Give this tool a prior and a dataset and it returns the exact posterior, its curve against the prior and the likelihood, and a credible interval you can quote.
-
How this is computed
✓ No data leaves your browser
✓ Verified against R's qbeta(), qnorm() and qgamma()
✓ Free, no sign-up
Every conjugate update is a weighted average
Three families, three formulas, one idea underneath.
A prior is not a mood. It is evidence, measured in the same units as your data, and the parameters count it. Beta(α0, β0) behaves like α0 + β0 imaginary trials you already ran. Gamma(α0, β0) behaves like α0 events already seen over β0 units of exposure. A normal prior with SD s0, against measurements of known SD σ, is worth n0 = σ² / s0² observations.
Once you count the prior that way, all three posterior means are the same sentence: a weighted average of what the prior said and what the data said, weighted by how many observations each one brings.
| Family | Prior is worth | Posterior mean |
|---|---|---|
| Beta-Binomial | α0 + β0 trials | (α0 + s) / (α0 + β0 + n) |
| Normal-Normal | n0 = σ² / s0² observations | (n0 m0 + n x̄) / (n0 + n) |
| Gamma-Poisson | β0 units of exposure | (α0 + y) / (β0 + t) |
This is why a strong prior and a weak prior can read the same data and reach different conclusions, and why the disagreement shrinks as the sample grows: the data's weight climbs with n while the prior's stays fixed. Switch between the weak and strong presets above and watch the posterior mean move while the data stays put.
Credible interval or confidence interval?
They are not rival spellings of the same thing. They answer different questions, and only one of them answers the question most people are actually asking.
A 95% credible interval is a statement about the parameter: given this prior and this data, there is a 95% probability that the parameter lies in this interval. The probability attaches to the unknown quantity, because in Bayesian statistics the unknown quantity has a distribution.
A 95% confidence interval is a statement about the procedure: the recipe that produced this interval would trap the true fixed parameter 95% of the time if you reran the whole experiment forever. The parameter is not random, so this particular interval either contains it or does not, and the 95% describes the method's long-run hit rate rather than this instance.
The frequentist statement is not a weaker version of the Bayesian one. It is a real guarantee, and it buys something valuable: coverage that holds without asking you to name a prior. That independence is exactly why regulators and referees like it. The Bayesian statement is more direct, and it is the one people usually want, which is why the confidence interval is so often misread as if it were a credible interval. Bayes lets you make that statement honestly, but it charges a price: you must state a prior, and the answer is only as defensible as that prior is.
| 95% credible interval | 95% confidence interval | |
|---|---|---|
| What is random | The parameter | The interval |
| The claim | 95% probability the parameter is in this interval | 95% of intervals built this way cover the true value |
| Needs a prior | Yes, and it shows in the answer | No |
| Can you say "95% sure it's in here" | Yes | No, though almost everyone does |
Here is the honest punchline, and you can watch it happen in the tool. Put a flat prior on the Normal-Normal family and the posterior becomes exactly Normal(x̄, σ²/n), so its 95% credible interval is arithmetically identical to the textbook z confidence interval, digit for digit. Same two numbers, two different claims. The gap between the philosophies is not usually in the arithmetic. It is in what you are allowed to say afterwards, and in whose prior you had to accept to say it.
The three families
Conjugacy is a property of a pair: the prior and the likelihood fit together so the posterior stays in the prior's family.
| Use it for | Prior | Data | Posterior |
|---|---|---|---|
| A probability or proportion | Beta(α0, β0) | s successes in n trials | Beta(α0 + s, β0 + n − s) |
| A mean, measurement SD known | Normal(m0, s0²) | x̄ from n readings, σ known | Normal(m1, s1²), precisions add |
| An event rate | Gamma(α0, rate β0) | y events over exposure t | Gamma(α0 + y, β0 + t) |
The Normal-Normal row hides the tidiest fact in Bayesian statistics. Work in precision, the reciprocal of variance, and the update is addition: the posterior precision is the prior precision plus the data precision, 1/s1² = 1/s0² + n/σ². Information adds up, so the posterior is always at least as sharp as either source alone. That is the general shape of the answer, and you can see it in the plot: the posterior curve is never wider than the narrower of the two curves feeding it.
This tool assumes σ is known for the Normal-Normal family. That is the price of the closed form. When σ is unknown too, the conjugate prior becomes normal-inverse-gamma and the posterior for the mean is a t distribution rather than a normal, which is a different tool. Requiring a proper prior is deliberate for the same reason: an improper prior such as Gamma(0.5, 0) has no curve to draw, even though its posterior is perfectly proper. For a deliberately weak gamma prior, use a small rate like 0.001.
Questions people ask
What is a conjugate prior?
A prior is conjugate to a likelihood when the posterior comes out in the same family as the prior. Beta is conjugate to the binomial, normal is conjugate to the normal with known variance, and gamma is conjugate to the Poisson. Conjugacy means the update is arithmetic rather than simulation: you add your data to the prior's parameters and read the answer off a closed form. It is also why these three pairings are taught first, and why MCMC exists for everything else.
What is the difference between a credible interval and a confidence interval?
A 95% credible interval says there is a 95% probability the parameter lies inside it, given the prior and the data. A 95% confidence interval makes no probability statement about this interval at all: it says the procedure that produced it would cover the true fixed parameter 95% of the time across repeated experiments. Both are useful and they answer different questions. With a flat prior the two are often numerically identical while still making different claims.
How do I choose a prior?
Read the prior as pseudo-observations. Beta(1, 1) is worth 2 imaginary trials and is nearly flat. Beta(50, 50) is worth 100 imaginary trials and will dominate a sample of 10. Pick a prior whose implied evidence matches what you actually knew before the data arrived, then check whether a weaker prior changes your conclusion. If it does, say so: that sensitivity is a finding, not a flaw to hide.
What does the posterior mean actually represent?
In all three conjugate families the posterior mean is a weighted average of the prior mean and the estimate from your data, and the weights are the pseudo-observation counts. As your sample grows, the data's weight grows with it and the prior's influence shrinks toward nothing. The tool shows both inputs and the prior's weight next to the answer so you can see which one is driving it.
Which family should I use?
Use Beta-Binomial for a probability or proportion from successes out of trials, Normal-Normal for a population mean when the measurement standard deviation is known, and Gamma-Poisson for an event rate from a count observed over some exposure such as time, distance or visits.
Why is the posterior median not the same as the posterior mean?
Because the posterior is usually skewed. Beta and gamma posteriors are symmetric only in special cases, so the mean gets pulled toward the long tail while the median stays at the halfway point of the probability. The normal posterior is the exception: it is symmetric, so its mean, median and mode coincide exactly. When mean and median disagree noticeably, the posterior is telling you the uncertainty is lopsided.