Session · 90 min · Available now · Modeling & Inference

TRUST THE CHAINS

MCMC in Practice

Tell a sampler that ran clean from a model that is actually right, and fix the three classic failures on your own data.

An agent can write the model. This session is about knowing when it is wrong.

$79 Buy now Buy once, watch any time. A person answers if it is the wrong one for you.
What you learn

The skills, and the artifact you leave with.

  • What the sampler actually did while it ran
  • What R-hat, effective sample size, trace, rank and energy plots each measure
  • How to tell a clean run from a right model
You leave with

A model-checking workflow you can run on every model you build, with the examples it was built on.

intercept = pm.Normal("intercept", mu=0, sigma=100000)
beta_fastball = pm.Normal("beta_fastball", mu=0, sigma=100000)
beta_slider = pm.Normal("beta_slider", mu=0, sigma=100000)
beta_curveball = pm.Normal("beta_curveball", mu=0, sigma=100000)
sigma = pm.HalfNormal("sigma", sigma=5)

# Expected value
mu = (
    intercept
    + beta_fastball * fastball_data
    + beta_slider * slider_data
    + beta_curveball * curveball_data
)

From the session's own notebook, model_fitting_mcmc.py, verbatim; verified against the file at build.

The problem

The sampler ran clean. That is not the same as the model being right, and telling the two apart is the whole hour.

Three decisions it teaches
  1. What to read in everything pm.sample returns, and which diagnostics decide whether to believe it
  2. How to recognize the three classic failures, non-identifiability, funnel geometry and slow mixing, and repair each
  3. How to judge the model on its predictions, with posterior predictive checks and PSIS-LOO

The artifact. A model-checking workflow you can run on every model you build, with the examples it was built on.

Pythonagents/viz/S13.py
2026-11-09T02:12:15.087607 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 65 70 75 80 85 90 95 100 release speed, mph 0 50 100 150 200 250 pitches Three pitch types, three speed distributions: one residual scale cannot fit them all CH n=1500 CU n=1500 FF n=1500 SL n=1500
Six thousand simulated pitches: release speed by pitch type, the data the model-checking loop runs on. Drawn at build from the data on this site by the code below.
The code that drew it
# Six thousand simulated pitches: release speed by pitch type, the data the model-checking loop runs on.
import sys, pathlib, csv
from collections import defaultdict
sys.path.insert(0, str(pathlib.Path(__file__).parent))
from _palette import plt, emit, GOLD, TEAL, AQUA, CREAM, MUTE

by = defaultdict(list)
for r in csv.DictReader(open("site/18-practice/pitch-speeds/files/pitches_2026.csv")):
    by[r["pitch_type"]].append(float(r["release_speed"]))
colors = {"FF": GOLD, "SL": TEAL, "CH": AQUA, "CU": CREAM, "SI": MUTE}
fig, ax = plt.subplots(figsize=(7.2, 4.0))
for pt, speeds in sorted(by.items(), key=lambda kv: -len(kv[1])):
    ax.hist(speeds, bins=40, range=(65, 102), histtype="step", lw=1.8, color=colors.get(pt, MUTE), label=f"{pt}  n={len(speeds)}")
ax.set_xlabel("release speed, mph"); ax.set_ylabel("pitches")
ax.set_title("Three pitch types, three speed distributions: one residual scale cannot fit them all")
ax.legend(frameon=False, fontsize=9)
emit(fig)

Data: Pitch speeds by type. Simulated for practice by AthlyticZ (agents/sim_data.py, seed 20261109). License CC BY 4.0.

What you get

Everything that exists for this session, and nothing that does not.

  • The recording90 minutes, yours to keep
  • The codeThe instructor's notebook and scripts, as taught
  • The datasetsBatted balls, Pitch speeds by type, with three practice questions each
Play with the data

Run the code, in your browser.

The chart on this page, drawn by code you can edit. R runs on webR and Python on Pyodide; nothing loads until you press Run, and nothing you type leaves the page.

Python
This chart is the code's result. Run recomputes it in your browser.
Posterior for each pitch type's average speed after twenty pitches, shaded to the 90% interval; the diamond is the average over all 1,500.

Edit me: Move the prior sd, or change first_n to 200 and run: the data overwhelms the prior.

Data: Pitch speeds by type (pitches_2026.csv). Simulated for practice by AthlyticZ (agents/sim_data.py, seed 20261109). License CC BY 4.0.

The code runs in your browser on Pyodide; nothing you type leaves the page.

Curriculum

What is covered, in order.

From the academy course record, as it is taught.

  1. MCMC in Practice: Fitting and Checking Bayesian Models with PyMC

    One live session, recorded, 90 minutes. Yours to keep and watch any time.

Chris Fonnesbeck
Your instructor Chris Fonnesbeck

PhD · Biostatistics @ Vanderbilt University Medical Center

Teaches the method the way it is used in the role above. The team page lists everything they teach here.

Also teaches Variational Inference in Sports, Hierarchical Modeling using PyMC in Baseball.

What is included

What is yours when you buy.

  • The full recording, 75 min
  • Yours to keep: watch it any time

Refunds. If you bought it and it is the wrong one for you, write to michael@athlyticz.com and a person will answer.

Questions

The ones that stop a purchase.

Is this too advanced, or too basic, for me?

Built for someone who already writes code in the session's language and wants the method, not the syntax. If the outcome line at the top reads like something you could use next week, it is pitched right. If it reads like a different job, start with the courses on /browse.

What exactly do I get, and for how long?

The full recording, yours to keep: buy once, watch any time. Masterclass subscribers get every live session for a year and can watch every recorded session for as long as they are a member. Everyone else can buy a recording on its own.

Do I need to install anything?

No. The recording plays in the browser.

What if it is not for me?

Twenty minutes on a call before you buy costs nothing, and the call is the fastest way to tell. If you bought it and it is the wrong one for you, email michael@athlyticz.com and a person will answer.

Want more?

Ten live hours of end-to-end project work every month.

The Masterclass is all of it, live and recorded, for $1,899 a year, or $199 a month. Paid by the month, it renews monthly at $199, cancel any time by replying to your receipt.

This session $79

MCMC in Practice. The recording, yours to keep.

Buy now
The Masterclass $1,899 a year, or $199 a month

Every live session this year, and every recording.

Join the Masterclass
Membership $2,999 a year

The whole catalog of courses plus the Masterclass.

Get Membership
$79Buy now