Bayes' Rule

Simulation-Based Inference

To follow the rest of this series you need to be comfortable with Bayes' rule. The textbook version takes a chapter. The version that actually matters for SBI takes one page. This is that page.

Every SBI method we look at — ABC, neural posterior estimation, normalizing-flow-based inference, the rest — is Bayes' rule wearing a different computational costume. Knowing the bare rule and what makes it hard in practice is the part that buys you the rest of the series.

The three ingredients

You have a parameter you want to know — a probability, a rate, a vector of physical constants, whatever. You have a model that says how observations arise from that parameter, the likelihood . And you have a prior , which is what you believed about before any data showed up.

After seeing an observation , you want to update your belief about . The thing you want is the posterior : the distribution over conditional on the data you actually saw.

The rule

Bayes' rule tells you how to get from prior + likelihood to posterior:

Three pieces in the numerator and one in the denominator. The numerator multiplies "what the data says about " (likelihood) by "what we already thought about " (prior). The denominator is the marginal probability of the data — what you get if you average the likelihood over the prior:

It's just a normalizing constant — its only job is to make the posterior integrate to 1. It doesn't depend on .

The annoying part

That normalizing constant causes most of the trouble in Bayesian practice. For any model more complicated than a textbook example, the integral over all has no closed form, and computing it numerically gets expensive fast. This is why most Bayesian techniques (MCMC, variational inference, importance sampling) avoid computing it explicitly and work with the unnormalized posterior instead:

"Proportional to" turns out to be enough for sampling, optimization, computing ratios — most of what you actually want to do. The unnormalized posterior values are not probabilities, but the ratios between them are, and that's what every Monte Carlo method secretly cares about.

A worked example

A classic. You flip a coin 10 times and get 7 heads. Is the coin fair? Let be the probability of heads. For a prior, suppose you think the coin is roughly fair but you're not sure, so — a soft bell shape peaked at 0.5. The likelihood is binomial: the probability of 7 heads in 10 flips at parameter is .

Apply Bayes:

Which, if you've seen the conjugacy trick, you'd recognize as . The posterior is more peaked than the prior because data, and shifted slightly above 0.5 because more heads than tails. Posterior mean: .

This is the textbook flavor of Bayesian inference. Conjugate prior + likelihood means the posterior stays in a known family with updated parameters. Everything has a closed form. No Monte Carlo needed.

Why SBI exists

Now imagine the model is harder. The coin has memory — its probability of heads depends on what came before. Or the observation isn't "7 heads in 10 flips" but a full sequence of timings, sounds, and contact angles. Or the "coin" is actually a 50-dimensional fluid simulation with eight unknown coefficients.

All of those still factor as in principle. But stops being something you can write down. The numerator of Bayes' rule has a piece you can't evaluate. The posterior, the thing you actually want, becomes inaccessible through direct calculation.

That's where SBI comes in. Even when the likelihood is intractable, the simulator still gives you samples from . ABC, the first SBI method we look at, is the most direct way to use those samples to do Bayesian inference. Every other method in this series is a different way of using simulator samples to get at the same posterior Bayes' rule is asking for.

One more thing — samples versus densities

In most of what follows, "the posterior" doesn't mean a function you evaluate at a point. It means a set of samples you can summarize however you want. From a thousand samples drawn from the posterior, you can read off the mean, the median, credible intervals, predictive distributions for new , and any nonlinear function of you care about.

This is liberating for SBI. The likelihood evaluation that classical methods need is used for finding modes and computing densities point-by-point. SBI methods skip ahead and produce samples directly, which is usually what you wanted in the first place — you were going to compute statistics out of those samples anyway.

With that in hand, the rest of the series is about different ways of producing those samples when the likelihood is gone. ABC is next.