Statistical Modeling for Machine Learning

Bayesian Estimation Introduction

Bayesian estimation as maintaining a full posterior distribution over parameters instead of collapsing immediately to one best value.

Lesson
19

Goal

Understand the conceptual shift from point estimation to Bayesian estimation: instead of asking for one best parameter, we keep a full probability distribution over plausible parameter values.

By the end of this lesson, you should be able to explain what extra information the posterior keeps that MLE and MAP throw away.

Motivation

MLE and MAP both end by reporting one parameter value:

But sometimes one number is not enough.

Two parameter values might both be plausible. Or one estimate might be sharp and confident while another is vague and uncertain. A single winner cannot show that difference.

Bayesian estimation keeps the entire distribution:

Not just which parameter is best, but how plausible each parameter value is relative to the others.

That extra structure is the main reason Bayesian methods are so expressive.

Prerequisites

Notation / Symbol Table

SymbolPlain-English nameMeaning
θ\thetaparameterThe unknown quantity we want to learn about.
DDdataThe observed evidence.
P(θ)P(\theta)priorBelief distribution before seeing the data.
P(Dθ)P(D \mid \theta)likelihoodHow compatible the data is with each parameter value.
P(θD)P(\theta \mid D)posteriorUpdated belief after incorporating the data.
P(D)P(D)evidenceNormalizing constant that makes the posterior integrate to 1.

Bayes’ rule for parameter estimation is

P(θD)=P(Dθ)P(θ)P(D).P(\theta \mid D) = \frac{P(D \mid \theta) P(\theta)}{P(D)}.

Core Ideas

Bayesian Estimation Keeps Uncertainty Explicit

Suppose we are estimating a coin’s bias θ\theta.

Point estimation says something like:

θ^=0.8.\hat{\theta} = 0.8.

Bayesian estimation says:

I do not know the true value exactly. I have a distribution over plausible values.

That distribution might be:

The posterior is an object that carries all of that information.

Prior, Likelihood, Posterior, Evidence

Each piece of Bayes’ rule answers a separate question:

The evidence is often the hardest term to feel intuitively. It is not an extra opinion about theta. It is the normalization step that turns an unscaled score into a proper distribution.

The Evidence Normalizes The Posterior

The denominator is

P(D)=P(Dθ)P(θ)dθ.P(D) = \int P(D \mid \theta) P(\theta)\, d\theta.

This expression sums up all the ways the model could have explained the observed data.

For point estimation tasks like MAP, we often ignore it because it does not change which theta is largest.

For full Bayesian estimation, we keep caring about it because we want the posterior to be a real probability distribution whose total mass is 1.

MAP Is One Summary Of The Posterior, Not The Posterior Itself

MAP picks the highest point of the posterior:

θ^MAP=argmaxθP(θD).\hat{\theta}_{MAP} = \arg\max_{\theta} P(\theta \mid D).

That can be useful, but it compresses the distribution down to one number.

What disappears when we do that?

The posterior keeps all of that.

Width Matters

Imagine two posterior distributions with the same peak location:

If we only report the mode, they look identical. But they mean very different things.

The narrow posterior says:

We have strong evidence concentrated near one parameter region.

The wide posterior says:

Many parameter values still fit reasonably well.

This is why Bayesian estimation is especially useful when we care about confidence, uncertainty, and downstream decisions.

Worked Example

Suppose your prior for a coin is centered near fairness, and then you observe two heads in two flips.

A Bayesian update should do two things at once:

  1. Shift probability mass toward larger values of θ\theta because heads are easier to explain when θ\theta is larger.
  2. Keep the posterior fairly broad because two flips are not much evidence.

So the correct story is not “the coin bias is now 0.8” or any other single number. The correct story is:

The posterior moved to the right, but it is still wide.

That sentence carries both direction and uncertainty, which is exactly what Bayesian estimation is trying to preserve.

Why This Shows Up In ML

Machine learning often has to make decisions under uncertainty:

Point estimates hide some of that information. Posterior distributions expose it.

Even when large-scale ML systems use approximations instead of exact Bayesian inference, the Bayesian picture still shapes the goals:

Exercises

  1. In your own words, what extra information does the posterior contain that MAP does not?
  2. If you observe two heads in two flips, should the posterior move toward larger or smaller θ\theta? Should it become narrow or remain broad?
  3. Why does the prior matter less after 2,000 observations than after 2 observations?
  4. Why would a Bayesian prefer to keep the whole posterior instead of reporting only the most likely parameter?

Implementation Exercise

Represent a discrete prior over coin-bias hypotheses in TypeScript:

type Hypothesis = {
  theta: number;
  prior: number;
};

Create a function that multiplies each prior weight by the Bernoulli likelihood of an observed flip, then normalizes the result to produce a posterior distribution over the finite hypothesis set.

Run it for a few hypotheses such as 0.3, 0.5, 0.7, and 0.9, and compare the posterior after:

Describe how the distribution’s width changes.

Reflection Questions