From 59e22b669f8f67f9d8d2c15613683760c3cc7e0d Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Sun, 25 Oct 2026 10:05:30 -0700 Subject: [PATCH] Combine adjacent tutorial documentation blocks --- .../tutorial_7_the_details.ipynb | 27 +++++-------------- .../tutorial_7_the_details.py | 12 +++------ 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/notebooks/chapter_1_introduction/tutorial_7_the_details.ipynb b/notebooks/chapter_1_introduction/tutorial_7_the_details.ipynb index ffbc333..111b2d8 100644 --- a/notebooks/chapter_1_introduction/tutorial_7_the_details.ipynb +++ b/notebooks/chapter_1_introduction/tutorial_7_the_details.ipynb @@ -1154,13 +1154,8 @@ "run, that is almost never a statement about which search is better. It is a statement about your parameter space,\n", "and the degeneracies and flat regions you have accidentally put in it.\n", "\n", - "Running more than one search tells you about your model, not just your searches!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ + "Running more than one search tells you about your model, not just your searches!\n", + "\n", "__Clipping__\n", "\n", "So far every model has been computable everywhere: any combination of values inside the priors gave a number.\n", @@ -1446,13 +1441,8 @@ "the value, because by the time it runs the damage to the derivative is already recorded. Safety has to live where\n", "the `nan` is created, not where it is detected.\n", "\n", - "A good likelihood value does not mean a good gradient!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ + "A good likelihood value does not mean a good gradient!\n", + "\n", "__Hamiltonian Diagnostics__\n", "\n", "Tutorial 6 introduced `BlackJAXNUTS`, the Hamiltonian sampler which follows the gradient along a trajectory instead\n", @@ -1544,13 +1534,8 @@ "acceptance rate falls, on a model whose parameter space has one of the pathologies we have studied. A degeneracy\n", "like the flip creates a long narrow ridge, and a trajectory following a ridge whose width changes along its length\n", "is exactly what makes a trajectory diverge. The diagnostics do not tell you the model is badly parameterized, but\n", - "they are often the first sign of it, and unlike the result itself they do not quietly look fine." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ + "they are often the first sign of it, and unlike the result itself they do not quietly look fine.\n", + "\n", "__Unit Cube Vs Physical__\n", "\n", "The last detail is the most fundamental, and it changes how you think about every prior you have written.\n", diff --git a/scripts/chapter_1_introduction/tutorial_7_the_details.py b/scripts/chapter_1_introduction/tutorial_7_the_details.py index 15be058..c60779c 100644 --- a/scripts/chapter_1_introduction/tutorial_7_the_details.py +++ b/scripts/chapter_1_introduction/tutorial_7_the_details.py @@ -805,7 +805,7 @@ def log_likelihood_function(self, instance) -> float: print(result_adam.info) -""" +r""" Put the results side by side. I want to separate two things carefully here: what these particular short runs actually showed, and what we know about the mechanisms independently of them. @@ -838,9 +838,7 @@ def log_likelihood_function(self, instance) -> float: and the degeneracies and flat regions you have accidentally put in it. Running more than one search tells you about your model, not just your searches! -""" -r""" __Clipping__ So far every model has been computable everywhere: any combination of values inside the priors gave a number. @@ -1054,7 +1052,7 @@ def model_data_from_instance(self, instance): print(f"value = {safe(-1.0)}") print(f"gradient = {jax.grad(safe)(-1.0)}") -""" +r""" Same value, and now a finite gradient. The lesson generalizes far beyond this function. A guard that checks the result of a calculation can only protect @@ -1062,9 +1060,7 @@ def model_data_from_instance(self, instance): the `nan` is created, not where it is detected. A good likelihood value does not mean a good gradient! -""" -r""" __Hamiltonian Diagnostics__ Tutorial 6 introduced `BlackJAXNUTS`, the Hamiltonian sampler which follows the gradient along a trajectory instead @@ -1126,7 +1122,7 @@ def model_data_from_instance(self, instance): f"Mean acceptance rate = {samples_nuts.samples_info.get('mean_acceptance')}" ) -""" +r""" On this dataset you should see few or no divergences, an effective sample size which is a decent fraction of the 300 samples drawn, and an acceptance rate near 0.8. That is what a healthy gradient sampler looks like. @@ -1135,9 +1131,7 @@ def model_data_from_instance(self, instance): like the flip creates a long narrow ridge, and a trajectory following a ridge whose width changes along its length is exactly what makes a trajectory diverge. The diagnostics do not tell you the model is badly parameterized, but they are often the first sign of it, and unlike the result itself they do not quietly look fine. -""" -""" __Unit Cube Vs Physical__ The last detail is the most fundamental, and it changes how you think about every prior you have written.