Bayesian Inference and Bayesian Statistics
  • Home
  • Start here
    • How this course works
    • Install the tools
    • Schedule and pacing
  • Parts
    • Part I Foundations
    • Part II Core Bayesian Inference
    • Part III Computation
    • Part IV Models
    • Part V Optimization and Diagnostics
    • Part VI Software Workflows
    • Part VII Advanced Topics
  • Exercises
  • Projects
  • References
  1. Start here
  2. Bayesian inference and Bayesian statistics
  • Start here
    • Bayesian inference and Bayesian statistics
    • Teaching philosophy
    • Tools and setup
    • Detailed syllabus and recommended pacing
  • Part I
    • Part I. Foundations of probability and Bayesian thinking
    • Probability foundations: measure spaces, conditional expectation, limit theorems, and transformations
    • Likelihood theory: score, Fisher information, MLE, profile likelihood, and comparison with posterior inference
    • Bayes’ theorem, sequential updating, and posterior prediction
  • Part II
    • Part II. Core Bayesian inference
    • Conjugate analysis: exact posteriors, predictive distributions, and marginal likelihoods
    • Loss functions, decision theory, and Bayesian estimation
    • Prior design: information, regularization, predictive checks, and sensitivity
  • Part III
    • Part III. Computational Bayesian methods
    • Numerical integration and approximation: quadrature, Laplace, importance sampling, and evidence estimation
    • Monte Carlo methods: integration, Monte Carlo error, variance reduction, and weighted ESS
    • Markov chain Monte Carlo: derivation, tuning, and diagnostics
    • Advanced MCMC: Hamiltonian Monte Carlo, NUTS, geometry, and diagnostics
    • Variational inference: ELBO, mean-field factorization, coordinate ascent, and approximation error
    • Sequential and online Bayesian computation: filtering, particle methods, and hidden-state models
    • The telescoping sampler
  • Part IV
    • Part IV. Bayesian models
    • Bayesian linear models: exact posterior structure, shrinkage, and prediction
    • Bayesian generalized linear models: logistic, count, ordinal, and multinomial regression
    • Hierarchical and multilevel models
    • Mixture models and latent variable models: heterogeneity, allocation, and label switching
    • Bayesian time series and state-space models: dynamics, filtering, and forecasting
    • Nonparametric Bayesian methods: Dirichlet processes, Gaussian processes, and flexible priors
    • Spatial and graphical Bayesian models: conditional independence, GMRFs, and structured priors
    • Bayesian causal inference: potential outcomes, modeling assumptions, and sensitivity
  • Part V
    • Part V. Optimization, tuning, and diagnostics
    • Optimization techniques in Bayesian statistics: MAP, curvature, and gradient methods
    • Tuning and calibration: proposal scales, warmup, chain length, and practical control
    • Diagnostics and model criticism: posterior checks, SBC, ESS, divergences, and predictive evaluation
  • Part VI
    • Part VI. Software workflows in R, Stan, and JAX
    • Bayesian workflow in R: simulation, summaries, diagnostics, and reproducibility
    • Stan workflow for hierarchical models and HMC diagnostics
    • JAX for gradient-based Bayesian computation
  • Part VII
    • Part VII. Advanced topics
    • Model selection and averaging: marginal likelihood, predictive utility, stacking, and projection
    • Robust Bayesian methods: heavy tails, contamination, misspecification, and generalized updating
    • Bayesian experimental design: expected utility, information gain, sequential design, and active learning
    • Communication and interpretation: posterior summaries, predictive uncertainty, decision reporting, and reproducibility
    • Capstone projects: end-to-end Bayesian workflow, project architecture, and assessment
  • Practice
    • Exercises and problem set design
    • Capstone projects
    • Bayesian project proposal template
    • Bayesian final project report template
  • Reference
    • Notation and assumptions
    • Measure-probability review
    • References and citation strategy
  • Course information
    • Instructor & credits
    • Evaluation
    • Course blueprint
    • Chapter-by-chapter expansion map
    • Deployment and online execution
  1. Start here
  2. Bayesian inference and Bayesian statistics

Bayesian inference and Bayesian statistics

A long-form course in probability, inference, computation, modelling, and workflow

Bayesian inference and Bayesian statistics

A full university course, written for advanced undergraduates, MSc and PhD students, and anyone with the background to work through it alone. Thirty-two chapters run from measure-theoretic foundations to modern probabilistic workflow, with derivations worked in full, runnable labs in R, Stan, and JAX, and exercises throughout.

The premise: Bayesian statistics is a workflow, not a formula. It starts with a probability model, passes through prior specification and posterior computation, and ends in decision-relevant summaries, predictive checks, and criticism of the model you just fitted (Bernardo and Smith 1994; Gelman et al. 2013, 2020).

Start here · Install the tools · Schedule

The course

I. Foundations

Probability spaces, conditional expectation, limit theorems, likelihood theory, Bayes’ theorem, exchangeability.

II. Core inference

Conjugate analysis, marginal likelihoods, decision theory, prior design and sensitivity.

III. Computation

Laplace approximation, Monte Carlo, MCMC, HMC and NUTS, variational inference, particle methods, the telescoping sampler.

IV. Models

Linear models, GLMs, hierarchical models, mixtures, state-space models, Gaussian processes, spatial and causal models.

V. Diagnostics

MAP estimation, tuning and calibration, convergence diagnostics, posterior predictive checking.

VI. Software

End-to-end workflows in R, Stan, and JAX, with reproducibility treated as part of the analysis.

VII. Advanced

Model selection and stacking, robustness, experimental design, communication, capstone work.

Where to start

  • I know some statistics
  • I’m an applied statistician
  • I implement algorithms
  • I’m just looking

Skim Part I and begin at conjugate analysis. Come back to the measure-theoretic material when a proof depends on it.

Then follow the main line: Bayesian linear models → hierarchical models → MCMC → diagnostics.

Start with conjugate analysis and Bayesian linear models, then go straight to the workflow chapters and fit something.

Return to Part I once the practice has given the theory something to attach to. Most people find it easier in that order.

Pair Part III with the JAX chapter, writing each sampler by hand before using a library version.

The telescoping sampler and the funnel geometry are the two places where implementation detail genuinely changes the statistics.

Read hierarchical and multilevel models. It has the derivations, the decision-theoretic argument, the geometry, and a worked example, so it shows the intended depth better than any description would.

What you need

Multivariable calculus, linear algebra to the level of eigenvalues and quadratic forms, undergraduate probability and statistics, and basic R or Python. No prior exposure to Bayesian methods.

The appendices cover notation, a measure-theoretic refresher, and installation.

Three tools, three purposes

The same model, three ways — this is the eight schools hierarchical model that runs through the course.

  • R
  • Stan
  • JAX

Simulation, conjugate calculations, custom samplers, and posterior summaries (R Core Team 2025; Bürkner et al. 2024).

# Partial pooling by hand: the shrinkage factor is the whole idea.
B <- sigma^2 / (sigma^2 + tau^2)
theta_hat <- (1 - B) * y + B * mu

A mature HMC and NUTS implementation, for hierarchical and nonlinear models (Carpenter et al. 2017; Hoffman and Gelman 2014).

parameters {
  real mu;
  real<lower=0> tau;
  vector[J] z;                      // standardised group effects
}
transformed parameters {
  vector[J] theta = mu + tau * z;   // non-centring: no funnel here
}
model {
  z ~ std_normal();
  y ~ normal(theta, sigma);
}

Automatic differentiation and JIT, for chapters where the point is to build the algorithm rather than call it (Bradbury et al. 2018).

# Writing HMC by hand is the fastest way to see what Stan does for you.
grad_logp = jax.grad(log_posterior)
p -= 0.5 * eps * -grad_logp(q)     # leapfrog half-step
q += eps * p

Every lab in the repository runs: R in labs/r/, Stan in labs/stan/, Python in labs/jax/.

Licence

Content is CC BY-NC-SA 4.0; code is MIT. Structure follows David (2023); presentation owes much to Kosmidis (2024). Full credits on the instructor page.

Back to top

References

Bernardo, José M., and Adrian F. M. Smith. 1994. Bayesian Theory. Wiley.
Bradbury, James, Roy Frostig, Peter Hawkins, et al. 2018. “JAX: Composable Transformations of Python+NumPy Programs.” GitHub Repository.
Bürkner, Paul-Christian, Jonah Gabry, Aki Vehtari, et al. 2024. Posterior: Tools for Working with Posterior Distributions.
Carpenter, Bob, Andrew Gelman, Matthew D. Hoffman, et al. 2017. “Stan: A Probabilistic Programming Language.” Journal of Statistical Software 76 (1): 1–32.
David, Claire. 2023. Introduction to Machine Learning. Online course notes.
Gelman, Andrew, John B. Carlin, Hal S. Stern, David B. Dunson, Aki Vehtari, and Donald B. Rubin. 2013. Bayesian Data Analysis. 3rd ed. CRC Press.
Gelman, Andrew, Aki Vehtari, Daniel Simpson, et al. 2020. “Bayesian Workflow.” arXiv Preprint arXiv:2011.01808.
Hoffman, Matthew D., and Andrew Gelman. 2014. “The No-u-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo.” Journal of Machine Learning Research 15 (47): 1593–623.
Kosmidis, Ioannis. 2024. APTS Statistical Modelling: Lecture Notes. Academy for PhD Training in Statistics.
R Core Team. 2025. R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing.
Teaching philosophy
Source Code
---
title: "Bayesian inference and Bayesian statistics"
subtitle: "A long-form course in probability, inference, computation, modelling, and workflow"
toc: false
page-layout: full
number-sections: false
---

::: {.hero}
# Bayesian inference and Bayesian statistics

A full university course, written for advanced undergraduates, MSc and PhD students, and anyone with the background to work through it alone. Thirty-two chapters run from measure-theoretic foundations to modern probabilistic workflow, with derivations worked in full, runnable labs in `R`, `Stan`, and `JAX`, and exercises throughout.

The premise: Bayesian statistics is a workflow, not a formula. It starts with a probability model, passes through prior specification and posterior computation, and ends in decision-relevant summaries, predictive checks, and criticism of the model you just fitted [@bernardo1994; @gelman2013; @gelman2020].

[Start here](teaching-philosophy.qmd) · [Install the tools](appendix/software-setup.qmd) · [Schedule](syllabus.qmd)
:::

## The course

::: {.grid-cards}
::: {.course-card}
### [I. Foundations](parts/part-i-foundations.qmd)
Probability spaces, conditional expectation, limit theorems, likelihood theory, Bayes' theorem, exchangeability.
:::

::: {.course-card}
### [II. Core inference](parts/part-ii-core-bayesian-inference.qmd)
Conjugate analysis, marginal likelihoods, decision theory, prior design and sensitivity.
:::

::: {.course-card}
### [III. Computation](parts/part-iii-computation.qmd)
Laplace approximation, Monte Carlo, MCMC, HMC and NUTS, variational inference, particle methods, the telescoping sampler.
:::

::: {.course-card}
### [IV. Models](parts/part-iv-models.qmd)
Linear models, GLMs, hierarchical models, mixtures, state-space models, Gaussian processes, spatial and causal models.
:::

::: {.course-card}
### [V. Diagnostics](parts/part-v-optimization-and-diagnostics.qmd)
MAP estimation, tuning and calibration, convergence diagnostics, posterior predictive checking.
:::

::: {.course-card}
### [VI. Software](parts/part-vi-software-workflows.qmd)
End-to-end workflows in `R`, `Stan`, and `JAX`, with reproducibility treated as part of the analysis.
:::

::: {.course-card}
### [VII. Advanced](parts/part-vii-advanced-topics.qmd)
Model selection and stacking, robustness, experimental design, communication, capstone work.
:::
:::

## Where to start

::: {.panel-tabset}
### I know some statistics

Skim [Part I](parts/part-i-foundations.qmd) and begin at [conjugate analysis](chapters/core/conjugate-analysis.qmd). Come back to the measure-theoretic material when a proof depends on it.

Then follow the main line: [Bayesian linear models](chapters/models/bayesian-linear-models.qmd) → [hierarchical models](chapters/models/hierarchical-and-multilevel-models.qmd) → [MCMC](chapters/computation/markov-chain-monte-carlo.qmd) → [diagnostics](chapters/practice/diagnostics-and-model-criticism.qmd).

### I'm an applied statistician

Start with [conjugate analysis](chapters/core/conjugate-analysis.qmd) and [Bayesian linear models](chapters/models/bayesian-linear-models.qmd), then go straight to the [workflow chapters](parts/part-vi-software-workflows.qmd) and fit something.

Return to [Part I](parts/part-i-foundations.qmd) once the practice has given the theory something to attach to. Most people find it easier in that order.

### I implement algorithms

Pair [Part III](parts/part-iii-computation.qmd) with the [JAX chapter](chapters/software/jax-gradient-based-bayes.qmd), writing each sampler by hand before using a library version.

[The telescoping sampler](chapters/computation/telescoping-sampler.qmd) and the [funnel geometry](chapters/models/hierarchical-and-multilevel-models.qmd) are the two places where implementation detail genuinely changes the statistics.

### I'm just looking

Read [hierarchical and multilevel models](chapters/models/hierarchical-and-multilevel-models.qmd). It has the derivations, the decision-theoretic argument, the geometry, and a worked example, so it shows the intended depth better than any description would.
:::

## What you need

Multivariable calculus, linear algebra to the level of eigenvalues and quadratic forms, undergraduate probability and statistics, and basic `R` or `Python`. No prior exposure to Bayesian methods.

The appendices cover [notation](appendix/notation.qmd), a [measure-theoretic refresher](appendix/measure-probability-review.qmd), and [installation](appendix/software-setup.qmd).

## Three tools, three purposes

The same model, three ways — this is the eight schools hierarchical model that runs through the course.

::: {.panel-tabset}
### `R`

Simulation, conjugate calculations, custom samplers, and posterior summaries [@r2025; @posterior2024].

```r
# Partial pooling by hand: the shrinkage factor is the whole idea.
B <- sigma^2 / (sigma^2 + tau^2)
theta_hat <- (1 - B) * y + B * mu
```

### `Stan`

A mature HMC and NUTS implementation, for hierarchical and nonlinear models [@carpenter2017; @hoffman2014].

```stan
parameters {
  real mu;
  real<lower=0> tau;
  vector[J] z;                      // standardised group effects
}
transformed parameters {
  vector[J] theta = mu + tau * z;   // non-centring: no funnel here
}
model {
  z ~ std_normal();
  y ~ normal(theta, sigma);
}
```

### `JAX`

Automatic differentiation and JIT, for chapters where the point is to build the algorithm rather than call it [@jax2018].

```python
# Writing HMC by hand is the fastest way to see what Stan does for you.
grad_logp = jax.grad(log_posterior)
p -= 0.5 * eps * -grad_logp(q)     # leapfrog half-step
q += eps * p
```
:::

Every lab in the repository runs: `R` in `labs/r/`, Stan in `labs/stan/`, Python in `labs/jax/`.

## Licence

Content is [CC BY-NC-SA 4.0](LICENSE-CONTENT.md); code is [MIT](LICENSE-CODE). Structure follows @david2023; presentation owes much to @ikosmidis2024. Full credits on the [instructor page](instructor-and-credits.qmd).

Course content licensed under CC BY-NC-SA 4.0; code examples licensed under MIT.

 
  • Report an issue

Site structure inspired by Claire David’s Intro to Machine Learning.