Interactive statistics
Module 11: Bayesian inference
Progresscompleted 0 / 63

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 โ†’
Breakdowns like this live in the channel

Data analytics in plain words: how to count metrics, how not to fool yourself in an A/B test, what gets asked in interviews and how this site gets built. The channel is in Russian.

Open the Telegram channel