Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 10: Bayesian inference

Bayesian inference: updating beliefs with data

Everything so far was the frequentist approach: the true value is considered fixed, and we ask "how surprising is the data if the hypothesis is true". The Bayesian approach looks differently: our knowledge of a quantity is a distribution of confidence, which the data UPDATES. Move the prior belief and the data β€” watch the posterior get born.

prior 0.50result 0.6601 Β· ΞΈ (true share/conversion)
▏ prior (belief before the data), center 0.50▏ likelihood (the data alone 34/50 = 0.68)▏ posterior (the result), center 0.66
posterior(ΞΈ) ∝ prior(ΞΈ) Γ— likelihood(data | ΞΈ) β†’ the result’s center 0.66 lies between 0.50 (prior) and 0.68 (data)

ΞΈ is the unknown true share (say, a button’s conversion). The gray curve is what you believe BEFORE the data (the prior); its center is set by "Prior belief" and its width by "Prior strength" (more strength β†’ narrower and more confident). The yellow dashed one is what the data ALONE says (k successes out of n): its peak sits at the share k/n. The blue one is the result (the posterior): it comes from multiplying the gray and the yellow and always lies BETWEEN them. Move the sliders: with little data the result leans toward the prior; at large n the yellow curve gets narrow and pulls the result toward itself β€” the data "overrides" the initial belief.

The gray curve is the prior distribution: what we believe about the share ΞΈ (say, a conversion rate) BEFORE the experiment. It is not one number but a whole distribution of plausibility over values. Put the prior mean where you expect the conversion, and set the "prior strength" to how confident you are.

What it means

The Bayesian approach works naturally with small data: instead of "too little to judge" it honestly shows a wide posterior β€” large uncertainty that narrows as observations accumulate.

In product A/B tests, Bayesian metrics ("probability that B beats A", "expected loss") are clearer to the business than a p-value. But the prior must be chosen thoughtfully: a strong biased prior with little data can drag the conclusion.

Where it shows up

Spam filters are historically Bayesian: the prior probability of spam is updated by the email's words (naive Bayes). The same mechanism drives medical diagnostics, where the disease base rate is updated by a test result (we saw this in the conditional probability lesson).

Recommender and search systems, A/B platforms, demand forecasts increasingly use Bayesian updating: it elegantly merges accumulated experience with new data in real time.

Definitions
Prior
the distribution of confidence about a quantity BEFORE seeing the data β€” past experience or a neutral assumption.
Likelihood
how probable the observed data is at each possible value of the quantity.
Posteriorposterior ∝ prior Γ— likelihood
the updated belief after the data. This is what conclusions and decisions are based on.
Bayes vs frequentist
frequentist: the quantity is fixed, the data is random. Bayes: the data is fixed, the uncertainty is expressed as a distribution over the quantity.
When the method lies (assumptions)

With little data the posterior almost entirely echoes the prior β€” the conclusion is exactly as honest as the prior. Check the sensitivity: does the answer change much under another reasonable prior?

"The probability that the effect exists" is a probability GIVEN your premises: the noise model and the prior. A crooked model or dependent data breaks Bayesian inference just as mercilessly as frequentist.

Deep dive: the math and the mechanism (optional)

The "sharpening" mechanism. The posterior at each point ΞΈ is the product of the prior and the likelihood: posterior(ΞΈ) ∝ prior(ΞΈ)Β·L(data|ΞΈ). With many observations the likelihood L is a product of each observation's probabilities, so it peaks sharply near the ΞΈ that best explains the data. Multiplying a narrow likelihood by a wide prior gives a narrow posterior at that peak β€” that is why data "wins" and narrows the belief.

Why little data β†’ the posterior stays near the prior: at small n the likelihood is still flat (the data rules out little), and the prior sets the shape. As n grows, the likelihood gets ever sharper and suppresses the prior β€” hence "data overrides preconceptions". Conjugate priors (Beta for shares, as in the widget) are convenient because the posterior stays in the same family β€” so the update reduces to a simple recalculation of the parameters.

Next β†’
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words β€” real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel