Fix My Tutorial
Report

Frequentism and Bayesianism: A Practical Introduction

Open the original tutorial
Fixed Python 3.12 · checked 17 Oct 2026 · model cost $0.076

After applying the fixes, the tutorial runs successfully under Python 3.12. The deprecated matplotlib `normed` parameter was replaced with `density`, Python 2‑style print statements were updated to function calls, and an indexing error in the 2D model setup was resolved by setting `ndim = 2`.

Partly checked: we ran 97% of the code on this page.

3 changes to make it work today

Block 7: Plot histogram and Gaussian

s7 · run_code migrate

Replace deprecated 'normed=True' with 'density=True' in plt.hist() call to match current matplotlib API.

@@ -1,4 +1,4 @@
# plot a histogram of the sample
-plt.hist(sample, bins=50, histtype="stepfilled", alpha=0.3, normed=True)
+plt.hist(sample, bins=50, histtype="stepfilled", alpha=0.3, density=True)
# plot a best-fit Gaussian

Sources

Block 15: Compute bootstrap means and print

s12 · run_code migrate

Add parentheses to print calls for Python 3 compatibility.

@@ -2,4 +2,4 @@
sig_samp = abs(samples[:, 1])
-print " mu = {0:.0f} +/- {1:.0f}".format(mu_samp.mean(), mu_samp.std())
-print " sigma = {0:.0f} +/- {1:.0f}".format(sig_samp.mean(), sig_samp.std())
+print(" mu = {0:.0f} +/- {1:.0f}".format(mu_samp.mean(), mu_samp.std()))
+print(" sigma = {0:.0f} +/- {1:.0f}".format(sig_samp.mean(), sig_samp.std()))

Sources

Block 17: Log prior for 2D and MCMC setup

s13 · run_code migrate

Change `dim, nwalkers = 2, 50` to `ndim, nwalkers = 2, 50` so the 2D model uses the correct dimension for starting guesses and the sampler.

@@ -10,5 +10,5 @@
# same setup as above:
-dim, nwalkers = 2, 50
+ndim, nwalkers = 2, 50
nsteps, nburn = 2000, 1000

Tell the author

Send them what broke and the fix, so the next reader doesn't hit the same error.

Badge

Add it to the tutorial so readers know when it was last checked.

Fix My Tutorial badge
Markdown
[![Fix My Tutorial](https://fix-my-tutorial.onrender.com/badge/ri-UJ8oz23_.svg)](https://fix-my-tutorial.onrender.com/r/ri-UJ8oz23_)
HTML
<a href="https://fix-my-tutorial.onrender.com/r/ri-UJ8oz23_"><img src="https://fix-my-tutorial.onrender.com/badge/ri-UJ8oz23_.svg" alt="Fix My Tutorial"></a>