• Solutions
  • Our Method
  • Learning
  • Blog
  • About Us
Categories
All (71)
bayesian (36)
classification (3)
decision-theory (1)
elections (1)
gaussian-processes (5)
hierarchical (5)
information-theory (3)
integration (2)
mcmc (19)
models (30)
montecarlo (5)
neural-networks (5)
optimization (10)
probability (16)
regression (15)
sampling (27)
statistics (26)
variational-inference (7)
visualization (1)

Course Notebooks

A browsable index of Univ.AI course notebooks.

Notebook archive

Browse the migrated course notebooks for probability, statistical computing, machine learning, Bayesian modeling, Monte Carlo, MCMC, Gaussian processes, and modern Python workflows.

Correlation Modeling with LKJ Priors
Modeling correlations using LKJ priors and Cholesky decomposition.
bayesian
regression
models

Models correlations in multivariate normal distributions using the LKJ prior. Covers correlation matrix construction, prior sensitivity via the eta parameter, and the…

Jul 2, 2025
Two-Component Gaussian Mixture
Identifiability and label-switching in two-component Gaussian mixtures.
bayesian
variational-inference
sampling
models

Simple 2-component Gaussian mixture model showcasing identifiability and label-switching problems without ordering, then solved with ordered transform. Uses NormalMixture…

Jun 25, 2025
Gaussian Mixture Models with ADVI
2D Gaussian mixtures with custom logp, Metropolis sampling, and mini-batch ADVI.
bayesian
variational-inference
sampling
models

Detailed 2D Gaussian mixture model with marginalization and ADVI. Covers custom logp via DensityDist, MCMC sampling, and ADVI with mini-batching using multivariate normals…

Jun 25, 2025
Marginalizing Over Discrete Variables
The log-sum-exp trick for marginalizing out cluster assignments in mixture models.
bayesian
mcmc
sampling
variational-inference
models

Demonstrates how to marginalize over discrete cluster assignments in Gaussian mixture models using the log-sum-exp trick. Covers NormalMixture, custom DensityDist with…

Jun 25, 2025
Mixture Models and MCMC
Gaussian mixtures, label-switching, and identifiability in MCMC sampling.
bayesian
mcmc
sampling
models

Explores Gaussian mixture models with MCMC sampling using Old Faithful data and synthetic 3-component mixtures. Demonstrates label-switching problems, identifiability…

Jun 25, 2025
Automatic Differentiation Variational Inference
From CAVI to scalable black-box VI with automatic differentiation.
bayesian
optimization
variational-inference

Covers the progression from CAVI to stochastic CAVI to ADVI, including transformation to unconstrained space, automatic differentiation for gradient computation, and…

Jun 18, 2025
Variational Autoencoder
Generative modeling with VAEs on MNIST using PyTorch.
neural-networks
optimization
variational-inference

Implements a variational autoencoder (VAE) in PyTorch for the MNIST dataset, covering the encoder-decoder architecture, the reparameterization trick, and the ELBO loss…

Jun 18, 2025
Variational Inference with Neural Networks
Bayesian neural network classification using ADVI in PyMC.
bayesian
neural-networks
classification
variational-inference

Builds a Bayesian neural network for binary classification on the moons dataset using variational inference (ADVI) in PyMC, demonstrating uncertainty quantification in…

Jun 18, 2025
Variational Inference
Approximating posteriors through optimization instead of sampling.
bayesian
optimization
variational-inference

Introduction to variational inference: the core idea of turning Bayesian inference into optimization, KL divergence, the ELBO, and coordinate ascent variational inference…

Jun 18, 2025
Bayesian Workflow: Zero-Inflated Poisson
Prior selection, simulation-based calibration, and posterior predictive checks for GLMs.
bayesian
regression
models

A complete Bayesian workflow applied to a zero-inflated Poisson model of monks producing manuscripts. Covers prior predictive checks, simulation-based calibration…

Jun 11, 2025
The Idea Behind the Gaussian Process
From multivariate normals to kernel-based function priors and predictive distributions.
gaussian-processes
regression
bayesian
probability

Starting from multivariate Gaussian marginals and conditionals, we build intuition for Gaussian Processes by constructing covariance matrices from kernels, drawing prior…

May 28, 2025
Gaussian Processes and Non-parametric Bayes
From kernel trick to infinite basis functions — the theory behind GP regression.
gaussian-processes
regression
bayesian

We develop the theoretical foundations of Gaussian Processes: the dual representation of Bayesian linear regression, kernel tricks, Mercer’s theorem, infinite basis function…

May 28, 2025
Inference for Gaussian Processes
Hyperparameter learning via empirical Bayes and MCMC with PyMC.
gaussian-processes
regression
bayesian
statistics

We tackle GP hyperparameter inference using the marginal likelihood: both Type-2 MLE (empirical Bayes) via optimization and full Bayesian MCMC via PyMC. The sockeye salmon…

May 28, 2025
Geographic Correlation and Oceanic Tools
Gaussian process covariance captures spatial correlation between island societies.
bayesian
regression
gaussian-processes
models

We extend the oceanic tools Poisson regression with a custom GP covariance matrix that models geographic correlation between societies. The inverse-square distance kernel…

May 28, 2025
GP Recap and Salmon Example
A condensed recap of GP theory applied to sockeye salmon recruitment.
gaussian-processes
regression
bayesian

A concise review of Gaussian Process fundamentals — MVN conditionals, kernel covariance, and GP regression — applied to the sockeye salmon stock-recruitment dataset with…

May 28, 2025
Poisson Regression — Model Comparison and Hierarchical Overdispersion
WAIC model comparison, ensemble averaging, and varying-intercepts for overdispersed counts.
bayesian
regression
hierarchical
models

We return to the oceanic tools dataset to illustrate model comparison using WAIC, model averaging with Akaike weights, counterfactual posterior predictives, and fighting…

May 28, 2025
Poisson Regression: Modeling Tool Diversity Across Islands
Centering, correlations, and counterfactual posteriors in Oceanic tool kit evolution.
bayesian
regression
mcmc
statistics

Analyzes technological diversity across Oceanic island societies using Poisson regression with interaction terms. Shows how parameter centering reduces posterior correlation…

May 21, 2025
Choosing Priors: From Flat to Weakly Informative
Uninformative, Jeffreys, and regularizing priors for Bayesian inference.
bayesian
statistics
probability
sampling

Explores how to choose priors that are robust to transformation and prevent overfitting without strongly biasing inference. Covers flat, improper, Jeffreys, and weakly…

May 21, 2025
Bayesian Regression with Normal Models
From heights to height-weight relationships using conjugate priors and posterior predictives.
bayesian
mcmc
regression
models
statistics

Demonstrates Bayesian regression by modeling height using normal distributions and PyMC. Covers posterior inference, the identifiability problem in regression parameters…

May 21, 2025
Identifiability in Bayesian Models
How parameter redundancy breaks MCMC convergence — and how priors can help.
bayesian
mcmc
models
statistics

Explores how unidentifiable parameters cause MCMC samplers to fail, even when derived quantities converge perfectly. Demonstrates convergence diagnostics that reveal the…

May 14, 2025
Gelman Schools and Hierarchical Pathology
Diagnosing and fixing funnel pathology in hierarchical models with reparameterization.
bayesian
hierarchical
mcmc

Explores the 8-schools hierarchical model to reveal how centered parametrizations create pathological funnel structures that trap HMC samplers. Shows how non-centered…

May 7, 2025
Hierarchical Bayesian Modeling: The 8 Schools Example
Learning to pool information across groups with non-centered parametrization.
bayesian
hierarchical
mcmc
sampling

Explores the Gelman Schools hierarchical normal-normal model, a foundational example in Bayesian statistics for estimating treatment effects across multiple groups.…

May 7, 2025
HMC/NUTS Tuning and Diagnostics
Why centered models diverge and non-centered models don’t — a hands-on HMC exploration.
mcmc
bayesian
hierarchical
sampling

Explores HMC/NUTS sampling tuning through hierarchical Bayesian models, demonstrating how parametrization, step-size adaptation, and leapfrog length affect sampling…

May 7, 2025
Data Augmentation
Iterative sampling via hidden variables using the Tanner-Wong algorithm and Gibbs.
mcmc
sampling
bayesian

Introduces data augmentation as iterative sampling via hidden variables. Contrasts the stochastic Tanner-Wong version with Gibbs sampling, showing how augmenting with latent…

Apr 30, 2025
Exploring Hamiltonian Monte Carlo
From typical sets to leapfrog integration: a detailed exploration of HMC and NUTS.
mcmc
sampling
optimization

Detailed exploration of Hamiltonian Monte Carlo following Neal and Betancourt. Covers typical set geometry, gradient-based smooth exploration, leapfrog integration, and the…

Apr 30, 2025
A Tetchy Gibbs Sampler
Gibbs sampling on a bimodal, highly-correlated posterior with lots of autocorrelation.
mcmc
sampling

Demonstrates Gibbs sampling on a bimodal, highly-correlated posterior distribution. Shows that conditional posteriors are Gaussian despite an ugly joint form, and…

Apr 30, 2025
Gibbs Sampling with Conjugate Conditionals
Exploiting conjugate prior pairs for efficient Gibbs sampling.
mcmc
sampling
bayesian

Demonstrates Gibbs sampling that exploits conjugate prior pairs like Beta-Binomial. Shows how conditional posteriors simplify to known distributions, making each Gibbs step…

Apr 23, 2025
The Metropolis-Hastings Algorithm
Sampling from complex distributions with asymmetric proposals and limited support.
mcmc
sampling

Extends the basic Metropolis algorithm to handle asymmetric proposal distributions and limited support domains. Demonstrates MH with a Weibull-like distribution using a…

Apr 23, 2025
Metropolis and Support Mismatch
Why combining rejection with Metropolis sampling wastes efficiency.
mcmc
sampling

Demonstrates the efficiency loss when combining rejection sampling with Metropolis by using a proposal distribution with larger support than the target. Shows that a…

Apr 23, 2025
Imputation and Convergence
A coal-mine disaster switchpoint model for convergence testing and posterior predictive checks.
mcmc
bayesian
models

Uses a coal-mine disaster switchpoint model to illustrate MCMC convergence testing and posterior predictive imputation. Detects a regulatory change around 1900 with a…

Apr 23, 2025
Discrete MCMC
Metropolis sampling from discrete distributions using proposal matrices.
mcmc
sampling

Demonstrates how to use Metropolis MCMC to sample from discrete distributions. Shows that MCMC handles discrete state spaces using proposal matrices that satisfy detailed…

Apr 16, 2025
Introduction to Gibbs Sampling
MCMC via alternating conditional sampling from a complex joint distribution.
mcmc
sampling
bayesian

Gibbs sampling enables sampling from complex joint distributions by alternately sampling from univariate conditionals. Demonstrates the method through a 2D example, deriving…

Apr 16, 2025
Markov Chains and MCMC
Stationarity, reversibility, and the mathematical foundation for Metropolis sampling.
mcmc
sampling
probability

Introduces Markov chains as the mathematical foundation for MCMC sampling. Covers stationarity, ergodicity, detailed balance, and the Metropolis algorithm, with a practical…

Apr 16, 2025
From Annealing to Metropolis
Understanding detailed balance and the Metropolis algorithm for sampling probability distributions.
mcmc
sampling

Explores the Metropolis algorithm as a method for sampling from probability distributions. Connects detailed balance from simulated annealing to the Metropolis-Hastings…

Apr 16, 2025
Hierarchical Bayesian Models
From partial pooling to shrinkage estimation with the rat tumors example.
bayesian
hierarchical
sampling

Introduces hierarchical Bayesian models as a framework for estimating parameters across related units by borrowing statistical strength from collective data. Demonstrates…

Apr 9, 2025
The EM Algorithm
Inferring parameters from incomplete data through iterative expectation and maximization.
statistics
models
optimization

Introduces the Expectation-Maximization algorithm for maximum likelihood estimation with missing or latent variables. Starts with estimating bivariate normal parameters from…

Apr 2, 2025
Generative vs Discriminative Models
Understanding discriminative boundaries vs. generative class models through logistic regression and LDA.
classification
models
bayesian

Explores Empirical Risk Minimization versus Bayesian learning, comparing discriminative and generative models. Uses a height/weight classification task to contrast logistic…

Mar 26, 2025
Mixture Models and Types of Learning
From generative classifiers to clustering: supervised, unsupervised, and semi-supervised approaches.
classification
models
statistics

Covers the three fundamental types of machine learning through the lens of Gaussian Mixture Models. Demonstrates how GDA works in supervised settings, contrasts with…

Mar 26, 2025
Utility, Risk, and Decision Theory
From utility functions to Bayes actions: applying decision theory to regression and model comparison.
decision-theory
bayesian
models

Covers decision theory fundamentals, explaining how to formulate and solve optimal decision problems using Bayesian methods. Demonstrates through a stock market prediction…

Mar 26, 2025
Regression in PyTorch
Building and training multi-layer perceptrons as universal function approximators.
neural-networks
optimization
regression

Demonstrates the Universal Approximation Theorem by implementing MLPs in PyTorch to fit complex 1D functions. Trains neural networks with ReLU and tanh activations using…

Mar 19, 2025
Multi-Layer Perceptron for Classification
Training neural networks to classify synthetic data with decision boundaries.
neural-networks
optimization
models

Implements multi-layer perceptrons for classification tasks using PyTorch. Generates synthetic datasets and trains networks to learn non-linear decision boundaries…

Mar 19, 2025
How Sigmoids Combine
Visualizing neural network function approximation through hidden layer activations.
neural-networks
optimization
visualization

Explores how sigmoid activation functions combine in MLPs to create increasingly complex function approximations. Trains neural networks with varying architectures —…

Mar 19, 2025
Gradient Descent and SGD
Optimization by following the slope downhill.
optimization
regression
models

Introduces gradient descent for optimization, starting with linear regression as a worked example. Covers batch gradient descent, stochastic gradient descent, mini-batch…

Mar 12, 2025
Logistic Regression and Backpropagation
From MLE classification to computing gradients through layers.
optimization
models
statistics

Develops logistic regression as a maximum likelihood classification model, then introduces backpropagation as the algorithm for computing gradients through layered…

Mar 12, 2025
Bayesian Regression
Putting priors on regression coefficients and updating with data.
bayesian
regression
models

Formulates linear regression in the Bayesian framework with conjugate normal priors on the coefficients. Derives the posterior distribution over weights, shows how the…

Mar 5, 2025
From the Normal Model to Regression
Building a Bayesian regression from Kung San census data.
bayesian
regression
models
sampling

Walks through the progression from a normal model to Bayesian linear regression using Howell’s Kung San height and weight data. Implements grid approximation and PyMC3 MCMC…

Mar 5, 2025
Lab: The Beta-Binomial Globe Model
Grid approximation, quadratic approximation, and MCMC in practice.
bayesian
sampling
models

Hands-on lab working through Bayesian inference on the globe-tossing model. Implements grid approximation, Laplace (quadratic) approximation, conjugate prior updates, and…

Feb 26, 2025
Importance Sampling
Sample where it matters most to compute integrals efficiently.
sampling
montecarlo
integration

Introduces importance sampling as a method for computing expectations and integrals by reweighting samples from a proposal distribution. Shows how choosing a good proposal…

Feb 26, 2025
The Inverse Transform
Turning uniform random numbers into any distribution you want.
sampling
probability

Introduces the inverse transform method for generating samples from arbitrary distributions using uniform random variables and the inverse CDF. Includes the Box-Muller…

Feb 26, 2025
The Normal Model
Conjugate priors for the workhorse of statistics.
bayesian
probability
statistics

Derives the normal-normal conjugate model for Bayesian inference on the mean of a Gaussian with known variance. Shows how the posterior interpolates between prior belief and…

Feb 26, 2025
Rejection Sampling
Accept or reject: a simple algorithm for hard distributions.
sampling
montecarlo

Presents von Neumann’s rejection sampling algorithm for drawing samples from distributions with known functional form. Covers the basic method and an enhanced version that…

Feb 26, 2025
Bayesian Statistics
Treating parameters as random variables changes everything.
bayesian
probability
statistics
sampling

Introduces Bayesian inference by contrasting it with the frequentist approach. Develops the normal-normal conjugate model, derives the MAP estimate, and shows how MCMC…

Feb 19, 2025
The Beta-Binomial Globe Model
Conjugate priors, Bayesian updating, and decision theory on a globe toss.
bayesian
probability
models

Develops the beta-binomial conjugate model for estimating the fraction of water on a globe. Covers prior selection, sequential Bayesian updating, loss functions, decision…

Feb 19, 2025
Sufficient Statistics and Exchangeability
When less data tells you everything, and order doesn’t matter.
bayesian
probability
statistics

Connects the exponential family to conjugate priors through sufficient statistics. Introduces exchangeability and de Finetti’s theorem, then develops the Poisson-Gamma…

Feb 19, 2025
Entropy and Maximum Entropy
Quantifying uncertainty and the distributions it favors.
information-theory
probability
statistics

Introduces information entropy as a measure of uncertainty and derives maximum entropy distributions. Shows how constraints on moments lead naturally to the exponential…

Feb 12, 2025
Divergence and Deviance
Measuring how far your model is from the truth.
information-theory
statistics
models

Develops KL divergence as a distance between distributions, connects it to cross-entropy and log-likelihood, and introduces deviance as a practical measure for model…

Feb 5, 2025
The Significance and Size of Effects
When a drug works, how much does it matter?
statistics
regression

Explores significance testing and effect size using a drug vs. placebo experiment. Demonstrates permutation tests, bootstrap confidence intervals, and Cohen’s d as…

Feb 5, 2025
Convexity and Jensen’s Inequality
Why the average of a function isn’t the function of the average.
probability
statistics

Introduces convex functions and proves Jensen’s inequality. Shows how convexity underpins key results in information theory and probabilistic modeling.

Feb 5, 2025
Understanding AIC
An information-theoretic shortcut for model selection.
information-theory
statistics
models

Explains the Akaike Information Criterion from first principles: how deviance, effective parameters, and information theory combine to estimate out-of-sample predictive…

Feb 5, 2025
Learning Without Noise
What happens when you fit a model to perfect data.
statistics
models

Introduces the learning problem through a noiseless example: fitting polynomial models to data, measuring in-sample vs out-of-sample error, and understanding how hypothesis…

Jan 29, 2025
Learning With Noise
Bias, variance, and the tradeoff that haunts every model.
statistics
models

Extends the learning framework to noisy data, where stochastic noise forces a tradeoff between model complexity and generalization. Derives the bias-variance decomposition…

Jan 29, 2025
Regularization
Taming complexity by penalizing parameters.
statistics
models

Introduces regularization as an alternative to model selection for controlling overfitting. Compares Ridge and Lasso regression, showing how a penalty term on coefficients…

Jan 29, 2025
Learning Bounds and the Test Set
How to honestly evaluate what your model has learned.
statistics
models

Formalizes out-of-sample error estimation using Hoeffding’s inequality and the train/test split. Walks through scikit-learn’s data pipeline for polynomial regression…

Jan 29, 2025
Validation and Cross-Validation
Why one split is never enough.
statistics
models

Explains why a separate validation set is needed to choose model complexity, and how cross-validation averages over multiple splits to give a more robust estimate of…

Jan 29, 2025
Maximum Likelihood Estimation
Find the parameters that make your data most probable.
statistics
models

Develops maximum likelihood estimation from first principles, deriving MLEs for the exponential, linear regression, and logistic regression models. Shows how MLE connects…

Jan 22, 2025
Basic Monte Carlo
Let randomness do the heavy lifting.
montecarlo
probability
sampling

Introduces Monte Carlo methods by estimating the area of a unit circle with random points. Covers the hit-or-miss method and rejection sampling as building blocks for Monte…

Jan 15, 2025
Expectations and the Law of Large Numbers
What you expect is what you get — eventually.
probability
statistics

Defines expected values, the Law of the Unconscious Statistician (LOTUS), and variance for discrete and continuous distributions. Demonstrates the Law of Large Numbers and…

Jan 15, 2025
Monte Carlo Integration
When calculus is hard, sample instead.
sampling
montecarlo
integration
probability

Formalizes Monte Carlo integration using uniform random samples and LOTUS, then extends to multidimensional integrals. Uses the Central Limit Theorem to estimate integration…

Jan 15, 2025
Sampling and the Central Limit Theorem
Why everything looks normal in the limit.
probability
statistics
montecarlo
sampling

Builds sampling distributions from repeated coin-flip experiments, showing how the sample mean and its variance behave as sample size grows. Derives the Central Limit…

Jan 15, 2025
Distributions Example: Elections
Simulating a presidential election with coin flips.
probability
statistics
elections

Simulates the 2012 US presidential election using Bernoulli coin flips for each state based on PredictWise probabilities. Introduces the Binomial distribution, the CLT’s…

Jan 8, 2025
Probability
From coin flips to Bayes’ theorem.
probability
statistics

Three ways to think about probability: symmetry, models, and long-run frequency, illustrated with coin-flip simulations. Covers the rules of probability, random variables…

Jan 8, 2025
No matching items