Bayesian Inference & Probabilistic Modelling

27 tutorials· Ordered reading path

Bayesian inference lets you update beliefs as evidence arrives. This path starts with the frequentist baseline (MLE), shows why Bayesian thinking is a natural extension, then builds toward real-world probabilistic models.

You will implement Metropolis-Hastings samplers, fit mixture models with EM, build Gaussian process regressors, and run hierarchical regressions in PyMC. Each tutorial is self-contained but follows a clear progression.

1

Maximum Likelihood Estimation in Python from Scratch

Build MLE from scratch in NumPy and SciPy across Bernoulli, Normal, and Multinomial: why we use log-likelihood, and how MLE connects to the EM algorithm.

2

GARCH Model in Python: A 36-Day Shock Half-Life

Fit a GARCH model in Python with NumPy and SciPy, verify it against arch, and compare volatility forecasts with EWMA on pinned S&P 500 returns.

3

Kelly Criterion in Python: Half Kelly, Estimated Inputs

Implement the Kelly criterion in Python. Simulate uncertain returns, compare fractional Kelly and inspect a GARCH allocation with explicit costs.

4

From Thermodynamics to ML: Entropy, KL and Mutual Info

Entropy, KL divergence and mutual information from first principles, with mode-seeking vs mean-seeking Python demos.

5

From MLE to Bayesian Inference: Why Your Estimate Needs a Prior

Bridge from Maximum Likelihood to Bayesian inference using the Beta-Binomial conjugate pair. Priors, posteriors, and why a 99% accurate test can be wrong.

6

AIC and BIC: Choosing the Right Model Without Overfitting

AIC vs BIC explained: build both information criteria from scratch, see why they penalise complexity differently, and when to use each for model selection.

7

Bayesian Model Comparison: The Evidence Framework

How Bayesian model comparison uses the marginal likelihood to pick model complexity: Bayes factors, BIC, AIC, and a polynomial regression demo in Python.

8

Sampling Methods Compared: Inverse-CDF, Rejection, Importance

Hands-on guide to Monte Carlo sampling: inverse-CDF, Box-Muller, rejection, and importance sampling, with Python code, animations, and a decision matrix.

9

MCMC Island Hopping: A Metropolis-Hastings Guide

The Metropolis-Hastings algorithm through the island hopping analogy. Proposal distributions, acceptance ratios, and why random walks recover any target.

10

Gibbs and Slice Sampling: Two Cures for Random-Walk MCMC

Gibbs sampling exploits conditionals; slice sampling adapts step size. Both cure random-walk Metropolis on correlated targets, with Python and animations.

11

Hamiltonian Monte Carlo: Two Knobs, Both Cliff Edges

Hamiltonian Monte Carlo in Python, built from the leapfrog up. It beats random-walk Metropolis 41 to 1 on a correlated target, and an 11% bigger step costs 18x.

12

MCMC for Mixture Models: Inferring Earthquake Regimes

Build a Metropolis-Hastings sampler from scratch to infer hidden regimes in earthquake data. Full posterior distributions instead of point estimates.

13

The EM Algorithm: An Intuitive Guide with the Coin Toss Example

Learn the Expectation-Maximisation algorithm through the classic two-coin problem. Understand soft assignments, weighted MLE, and why EM always converges.

14

Gaussian Mixture Models: The EM Algorithm in Practice

Implement Gaussian Mixture Models from scratch using the EM algorithm. Cluster Old Faithful eruptions and understand responsibilities and convergence.

15

Approximate Inference: From MCMC to Variational Bayes

Derive variational Bayesian linear regression in NumPy, compare it to PyMC NUTS on the same dataset, and watch the lower bound pick the true polynomial degree.

16

Variational Autoencoders in NumPy: Three Digits, No KL Term

Build a variational autoencoder from scratch in NumPy with hand-derived gradients. Measure what the KL term buys: without it the model can only generate 3 of 10 digits.

17

Diffusion Models from Scratch: Fifty Steps, If You Keep the Noise

Build a diffusion model from scratch in NumPy with hand-derived gradients. Measured over three seeds: DDIM's deterministic sampler is not worse on average, it is unreliable.

18

Gaussian Process Regression: The Bayesian Approach to Curve Fitting

Gaussian process regressor from scratch in NumPy. How kernels encode smoothness, posteriors collapse with data, and GPs power Bayesian optimisation.

19

Bayesian Neural Networks: Laplace and Evidence Framework

Turn a point-estimate MLP into a Bayesian neural network with the Laplace approximation and the evidence framework. Fit a GELU net with error bars.

20

Relevance Vector Machine vs SVM in Python

Build a relevance vector machine from scratch. The RVM gives sparser, calibrated alternatives to the SVM via ARD priors and evidence maximisation.

21

Conformal Prediction: 90% Coverage, 29% Where It Counts

Split conformal prediction in Python delivers exactly the coverage you ask for. Measured per class it gives 95% on the common ones and 29% on the rare.

22

Probabilistic PCA, EM-PCA, Bayesian PCA, Factor Analysis

Probabilistic PCA as a latent variable model. EM-PCA, Bayesian PCA with ARD that picks dimensionality automatically, and Factor Analysis. From scratch in NumPy.

23

Bayesian Networks for Clinical Decision Support

Build a Bayesian network in pgmpy from a toy lung-cancer dataset. Parameter learning, d-separation, structure search, causality.

24

Bayesian Online Changepoint Detection in Python

Detect regime shifts in real time with BOCD. Track posterior probabilities on S&P 500 data, choose your detection threshold, and compare with offline PELT.

25

Hierarchical Bayesian Regression with PyMC: When Groups Share Strength

Hierarchical Bayesian regression in PyMC for insurance claim severity across policy types. Partial pooling, shrinkage, and MCMC diagnostics with ArviZ.

26

Custom Likelihoods in PyMC: One-Inflated Beta Regression

One-Inflated Beta regression in PyMC with a custom log-likelihood for loan data. Handle boundary spikes, write Beta densities, and interpret with ArviZ.

27

Bayesian Survival Analysis with PyMC: Modelling Customer Churn

Bayesian accelerated failure time model in PyMC for customer churn. Censored data with pm.Potential, Weibull vs Log-Logistic, and ArviZ survival curves.

Related Tools

Stay in the loop

Get notified when new tutorials and deep-dives are published. No spam, unsubscribe anytime.

Bayesian Inference FAQ

Common questions about this topic