Spring 2026 • Northeastern University

Bayesian Inference: Grid Approximation

This interactive demo illustrates Bayesian inference using grid approximation. Imagine we're surveying people about whether they drink coffee. We want to estimate the true proportion of coffee drinkers in the population.

How It Works

  1. Prior: Choose your prior belief (uniform or centered on a specific value)
  2. Data: Each "Yes" or "No" click represents a survey response
  3. Posterior: The distribution updates based on Bayes' theorem

Original concept from Probabilistic Machine Learning course (Summer Term 2025)
University of Tübingen, taught by Professor Philipp Hennig


Controls

Data Collection

Responses: total ( yes, no)

Prior Selection

Visualization


Posterior Distribution

  • Blue area: Posterior distribution (our updated belief)
  • Red dashed line: Posterior mean ()
  • Blue dashed lines: % Credible interval
  • Gray dashed line: Prior distribution ()

Understanding the Math

Bayes' Theorem

Where:

Likelihood Function

For binomial data (yes/no responses), the likelihood is:

where is the number of "yes" responses and is total responses.

Prior Distributions

Uniform Prior: All values of are equally likely:

Gaussian Prior: Centered at with standard deviation :

Grid Approximation

Instead of solving analytically, we:

  1. Create a fine grid of possible values from 0 to 1
  2. Compute the likelihood at each grid point
  3. Multiply by the prior
  4. Normalize so the total probability sums to 1

This gives us a discrete approximation of the true posterior distribution!