TapCub is live — analytics, insights and live chat, free on one platform
Glossary

What is Bayesian analysis? Prior and posterior explained

Bayesian analysis treats unknowns such as conversion rates as probability distributions and updates them with data. One worked example from prior to posterior, how much the prior matters, and what probability to be better means.

Lin Zhou Reviewed by Su He Also called Bayesian statistics Last updated Nov 29, 2026 Glossary

Quick answer

Bayesian analysis is a statistical approach that treats unknowns, such as a conversion rate, as probability distributions and updates them with data via Bayes theorem: prior times likelihood gives a posterior, from which credible intervals and direct probabilities are read.

Formula: P(θ | data) = P(data | θ) × P(θ) ÷ P(data); Beta(a, b) prior + k conversions in n trials → Beta(a + k, b + n − k) posterior

What is Bayesian analysis?

Bayesian analysis is a way of doing statistics in which every unknown quantity, such as a conversion rate, is described by a probability distribution, and that distribution is updated with data using Bayes' theorem. You start with a prior (what is plausible before the data), multiply it by the likelihood (how probable the observed data is for each possible value) and get a posterior (what is plausible after the data).

The payoff is in the kind of answer you get. Instead of "if there were no difference, data this extreme would appear 23.5% of the time", a Bayesian analysis says "given the data and the prior, there is an 88% probability that version B converts better than version A". That is the sentence most product and marketing teams actually want to say, and it is only valid inside the Bayesian framework.

This page works through one conversion-rate example from prior to posterior, explains credible intervals and probability to be better, shows how much the prior matters, and sets Bayesian results next to p-values and confidence intervals.

Bayes' theorem in one line

For an unknown parameter θ (theta) and observed data:

P(θ | data) = P(data | θ) × P(θ) ÷ P(data)

TermNameIn a conversion-rate problem
P(θ)PriorWhat conversion rates you consider plausible before the test
P(data given θ)LikelihoodHow probable "48 conversions in 1,000 sessions" is for each possible rate
P(data)EvidenceA normalizing constant so the posterior sums to 1
P(θ given data)PosteriorPlausible conversion rates after seeing the data

For conversion rates there is a shortcut. If the prior is a Beta(a, b) distribution and you observe k conversions in n trials, the posterior is exactly Beta(a + k, b + n − k). This conjugate result is a standard textbook case (Gelman et al., Bayesian Data Analysis, chapter 2). Its mean is (a + k) ÷ (a + b + n). You can read a and b as "prior conversions" and "prior non-conversions".

Worked example: from prior to posterior

Sample data: a landing page gets 1,000 sessions and 48 conversions.

  1. Prior. With no strong view, use Beta(1, 1), which treats every rate from 0% to 100% as equally plausible. It is worth only 2 pseudo-sessions.
  2. Update. Posterior = Beta(1 + 48, 1 + 1,000 − 48) = Beta(49, 953).
  3. Summarize. Posterior mean = 49 ÷ 1,002 = 4.89%. The central 95% of the posterior lies between 3.64% and 6.31%. Computed by numerically integrating the Beta density in Python.
  4. Ask a direct question. Probability that the true rate is above 5%: 42.0%. That is a statement about the rate itself, which a p-value cannot give you.

The 3.64% to 6.31% range is a 95% credible interval: given this model and prior, the rate lies inside it with 95% probability.

How much does the prior matter?

Same data (48 of 1,000), three priors. Every number was recomputed in Python:

PriorPrior meanWorth (pseudo-sessions)PosteriorPosterior mean95% credible interval
Flat Beta(1, 1)50%2Beta(49, 953)4.89%3.64% to 6.31%
Informed Beta(20, 380)5.0%400Beta(68, 1,332)4.86%3.79% to 6.04%
Skeptical Beta(2, 98)2.0%100Beta(50, 1,050)4.55%3.40% to 5.85%

Three rules come out of this table:

  • Data dominates once n is much larger than the prior's weight. The flat and informed priors give almost the same mean because 1,000 real sessions outweigh 2 or 400 pseudo-sessions.
  • An informed prior narrows the interval. Using last quarter's 5% rate as 400 sessions' worth of evidence cut the interval width from 2.67 points to 2.25 points.
  • A prior that disagrees with the data pulls the estimate. The skeptical 2% prior moved the mean from 4.89% to 4.55%. Write the prior down before the test and justify its weight; a prior chosen after seeing the data is not a prior.

Probability to be better: comparing two versions

Sample data: version A converts 48 of 1,000 sessions, version B converts 60 of 1,000. With flat priors:

Version AVersion B
PosteriorBeta(49, 953)Beta(61, 941)
Mean4.89%6.09%
95% credible interval3.64% to 6.31%4.69% to 7.65%
  • Probability B is better than A: 88.2% (numerical integration over both posteriors).
  • Relative lift of B over A: median +24.6%, with a 95% interval from −13.4% to +80.7% (400,000 Monte Carlo draws).
  • Frequentist comparison on the same data: a two-proportion z-test gives z = 1.19 and p = 0.235, which is "not significant" at the usual 0.05 level.

Both analyses agree that the data is inconclusive; they phrase it differently. The Bayesian version adds something useful for a decision: an 88% chance B is better, but a lift interval that still includes losing 13%. If shipping B is cheap and reversible, 88% may be enough; if it is expensive, collect more data. The two schools are compared on one test in more depth in Bayesian vs frequentist.

Credible interval vs confidence interval

Bayesian credible intervalFrequentist confidence interval
Statement"The rate is in this range with 95% probability, given the model and prior""This procedure captures the true rate in 95% of repeated samples"
Needs a priorYesNo
Can you say "95% probability the rate is in here"?YesNo, strictly speaking
Changes when you peek at dataNo; the posterior is valid at any timeRepeated peeking inflates false positives unless the design accounts for it
Typical number3.64% to 6.31% hereClose to the same range with large n and a flat prior

The American Statistical Association's 2016 statement on p-values lists six principles; the second is that p-values do not measure the probability that the studied hypothesis is true. That is exactly the probability a posterior gives you, at the price of stating a prior. For the frequentist workflow, see hypothesis testing.

Common mistakes

  • Picking the prior after seeing results. It turns the analysis into a story. Fix and document it first.
  • Reading 88% as "88% lift". Probability to be better says nothing about the size of the difference; report the lift interval too.
  • Ignoring the cost of being wrong. Decide in advance what probability, and what worst case in the interval, is acceptable for this decision.
  • Treating a Bayesian test as immune to bad data. Bot traffic, duplicate events and sample ratio problems corrupt the likelihood just as they corrupt a z-test.
  • Using a strong prior on a small test. With 200 sessions, a Beta(20, 380) prior is worth twice the data and mostly reflects your assumption.

Feeding a Bayesian comparison with TapCub data

TapCub does not run Bayesian A/B engines or split traffic. It supplies the k and n that go into the formula above, from clean data.

  1. Get the counts. In All-platform analytics › Behavior › Behavior analysis, build a funnel to the conversion event and filter or segment by the version you shipped (for example an event property or landing page). Each row gives conversions (k) and entrants (n).
  2. Keep bots out of n. Recognized crawlers and AI bots are reported separately in Web analytics › Bots and do not enter human visitors and sessions, so the denominator is people.
  3. Use the small-sample case honestly. Live chat › Reports › Conversion attribution shows the goal conversion of visitors who chatted against those who did not, with relative lift = chatted rate ÷ no-chat rate − 1, and warns when fewer than 30 people chatted. That is where a Beta posterior and its interval are more informative than a single lift figure.
  4. Run the update yourself. Plug k and n into Beta(a + k, b + n − k) in a notebook or spreadsheet, and record the prior you chose next to the result.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Lin Zhou

Product Experience Specialist

Writes about product experience, practical workflows, and growth, turning complex processes into clear steps for everyday decisions.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What is the difference between Bayesian and frequentist analysis?

Frequentist analysis treats the parameter as fixed and asks how likely the data would be under a hypothesis, giving p-values and confidence intervals. Bayesian analysis treats the parameter as uncertain, combines a prior with the data and gives direct probabilities, such as an 88% chance that B beats A.

What is a credible interval?

A credible interval is a range that contains the unknown parameter with a stated probability, given the model and prior. With a flat prior and 48 conversions in 1,000 sessions, the 95% credible interval for the conversion rate is 3.64% to 6.31%.

How do I choose a prior?

Use past data for the same metric and decide how much weight it deserves, expressed as pseudo-observations, before running the test. If you have no reliable history, use a weak prior such as Beta(1, 1). Document the choice and check how sensitive the result is to it.

Is 95% probability to be better enough to ship?

It depends on the cost of being wrong. Also look at the lift interval: a high probability to be better can coexist with a plausible loss. Set the threshold and the acceptable worst case before the test, and consider data quality first.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics