Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interpret probabilistic models from first principles. It is the teaching compani
## Repository Structure

- `scripts/` — Runnable Python tutorial scripts:
- `chapter_1_introduction/` — Models, fitting data, non-linear searches, results and samples, and a prose-only scientific workflow closing tutorial
- `chapter_1_introduction/` — Models, fitting data, non-linear searches, results and samples, gradients and JAX autodiff, the details that make a fit succeed or fail, a prose-only scientific workflow closing tutorial, and an optional Bayesian formalism tutorial
- `chapter_3_graphical_models/` — Individual / graphical / hierarchical models, Expectation Propagation
- `simulators/` — Simulator scripts that generate the tutorial 1D datasets at runtime
- `notebooks/` — Jupyter versions, generated from `scripts/` (do not edit directly)
Expand Down Expand Up @@ -64,7 +64,7 @@ The navigator catalogue — `llms-full.txt` + `workspace_index.json` — is what
gates; it is rebuilt by the same PyAutoHands generate/merge flow that builds the notebooks. Commit
regenerated notebooks and catalogue alongside the script changes.

`tutorial_6_scientific_workflow.py` is prose-only by design: its generated notebook must contain no
`tutorial_8_scientific_workflow.py` is prose-only by design: its generated notebook must contain no
code cells, including Colab setup. Verify this after regeneration.

## Bulk-edit safety
Expand Down
8 changes: 7 additions & 1 deletion config/build/markdown_examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@
max_minutes: 120
- script: scripts/chapter_1_introduction/tutorial_5_results_and_samples.py
max_minutes: 90
- script: scripts/chapter_1_introduction/tutorial_6_scientific_workflow.py
- script: scripts/chapter_1_introduction/tutorial_6_gradients.py
max_minutes: 60
- script: scripts/chapter_1_introduction/tutorial_7_the_details.py
max_minutes: 60
- script: scripts/chapter_1_introduction/tutorial_8_scientific_workflow.py
max_minutes: 1
- script: scripts/chapter_1_introduction/tutorial_optional_bayesian_formalism.py
max_minutes: 30
15 changes: 11 additions & 4 deletions config/build/profile_smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ defaults:
# ever matched a file here.
#
# Do not copy override patterns between repos; a pattern that matches nothing
# is silently inert, not an override. `overrides: []` is written explicitly
# because env_config.py reads `.get("overrides", [])` — a bare `overrides:`
# key would load as None and raise on iteration.)
overrides: []
# is silently inert, not an override. Patterns without a '/' match the file
# stem exactly, so the two entries below match only the chapter 1 gradient
# tutorials. Never leave the `overrides:` key with an empty value — a bare
# `overrides:` loads as None; write `overrides: []` if every entry is removed.)
overrides:
# The gradient tutorials teach JAX autodiff searches (MultiStartAdam, BlackJAXNUTS),
# which refuse to run with use_jax=False, so JAX stays on for them.
- pattern: "tutorial_6_gradients"
set: {PYAUTO_DISABLE_JAX: "0"}
- pattern: "tutorial_7_the_details"
set: {PYAUTO_DISABLE_JAX: "0"}
8 changes: 7 additions & 1 deletion llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ AUTO-GENERATED by PyAutoHands — do not edit by hand; regenerate with generate.
- Contents: Data, Model, Analysis, Alternative Syntax, Collection, Search, Model Fit, Result, Why Modeling is Hard, Prior Tuning, Reducing Complexity, Search More Thoroughly, Summary, Run Times, Model Mismatch, Astronomy Example, Wrap Up
- [Tutorial 5: Results And Samples](scripts/chapter_1_introduction/tutorial_5_results_and_samples.py): In this tutorial, we'll cover all of the output that comes from a non-linear search's `Result` object.
- Contents: Data, Reused Functions, Model Fit, Result, Samples, Parameters, Figures of Merit, Instances, Vectors, Labels, Posterior / PDF, Plot, Errors, PDF, Other Results, Sample Instance, Bayesian Evidence, Derived Errors (PDF from samples), Samples Filtering, Latex
- [Tutorial 6: Scientific Workflow](scripts/chapter_1_introduction/tutorial_6_scientific_workflow.py): You can now compose a model, fit it to data and interpret its results. A scientific study often repeats these steps for many datasets, competing models and different non-linear searches. The next challenge is keeping those fits organized so that you can understand and compare them.
- [Tutorial 6: Gradients](scripts/chapter_1_introduction/tutorial_6_gradients.py): In tutorial 3, describing how a maximum likelihood estimator works, we said it "evaluates the likelihood at nearby points to estimate the gradient, determining the direction in which to move up in parameter space". That sentence slipped by quickly, but it hides one of the most important ideas in model-fitting: the search does not have to be blind, because the likelihood surface has a slope, and the slope tells us which way is up.
- Contents: Data, Model, Analysis, Gradients, Finite Differencing, JAX and Autodiff, Maximum Likelihood Estimation (MLE), Markov Chain Monte Carlo (MCMC), Nested Sampling, Errors From Curvature, Wrap Up
- [Tutorial 7: The Details](scripts/chapter_1_introduction/tutorial_7_the_details.py): In tutorial 6 we opened up the non-linear search and looked at how it moves. We saw that some searches only ever ask the likelihood function "what is the value here?", whilst gradient based searches also ask "and which way is uphill?", and that **PyAutoFit** can answer the second question exactly by using JAX to differentiate the likelihood function.
- Contents: Data, Model, Analysis, Parameterization, Assertions, Plateaus, Comparing Searches, Clipping, NaN Diagnostics, Unit Cube Vs Physical, Summary
- [Tutorial 8: Scientific Workflow](scripts/chapter_1_introduction/tutorial_8_scientific_workflow.py): You can now compose a model, fit it to data and interpret its results. A scientific study often repeats these steps for many datasets, competing models and different non-linear searches. The next challenge is keeping those fits organized so that you can understand and compare them.
- [Tutorial Optional: Bayesian Formalism](scripts/chapter_1_introduction/tutorial_optional_bayesian_formalism.py): Every tutorial in this chapter has been an exercise in Bayesian inference, and not one of them wrote down a single equation of probability theory. That was deliberate. The **HowToFit** lectures are built on the conviction that you can learn to fit models to data properly, and interpret the results correctly, without first sitting through a course on Bayesian statistics.
- Contents: Bayes Theorem, Data, The Model, The Likelihood, The Prior, The Posterior, Maximum Likelihood Vs Maximum A Posteriori, Marginalization, The Evidence, Gradients, Wrap Up

## chapter_3_graphical_models

Expand Down
3 changes: 3 additions & 0 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ analysis?" below).
- **How does a non-linear search work?** → [scripts/chapter_1_introduction/tutorial_3_non_linear_search.py](scripts/chapter_1_introduction/tutorial_3_non_linear_search.py): Parameter space, priors, MLE / MCMC / nested sampling, and which to use.
- **Why do model fits fail, and how do I fix them?** → [scripts/chapter_1_introduction/tutorial_4_why_modeling_is_hard.py](scripts/chapter_1_introduction/tutorial_4_why_modeling_is_hard.py): Prior tuning, reducing complexity, searching more thoroughly.
- **What's in the `Result` / how do I read samples?** → [scripts/chapter_1_introduction/tutorial_5_results_and_samples.py](scripts/chapter_1_introduction/tutorial_5_results_and_samples.py): Samples, instances, PDFs, errors, Bayesian evidence, LaTeX output.
- **How does a search know which way is "up" / what is a gradient?** → [scripts/chapter_1_introduction/tutorial_6_gradients.py](scripts/chapter_1_introduction/tutorial_6_gradients.py): Gradients of the log likelihood, finite differencing, JAX autodiff, gradient vs non-gradient searches, errors from curvature.
- **My fit looks reasonable but the answer is wrong — what am I missing?** → [scripts/chapter_1_introduction/tutorial_7_the_details.py](scripts/chapter_1_introduction/tutorial_7_the_details.py): Parameterization and mirror solutions, assertions, plateaus, clipping, NaN diagnostics, the unit cube.
- **Where is the Bayesian maths behind all of this?** → [scripts/chapter_1_introduction/tutorial_optional_bayesian_formalism.py](scripts/chapter_1_introduction/tutorial_optional_bayesian_formalism.py): Bayes' theorem, likelihood, prior, posterior, marginalization and evidence, mapped onto what chapter 1 already computed.
- **I have many datasets with a shared parameter — what's the right tool?** → [scripts/chapter_3_graphical_models/tutorial_2_graphical_model.py](scripts/chapter_3_graphical_models/tutorial_2_graphical_model.py): Factor graphs and graphical models vs one-by-one fits.
- **What is a hierarchical model / Expectation Propagation?** → [scripts/chapter_3_graphical_models/tutorial_4_hierachical_models.py](scripts/chapter_3_graphical_models/tutorial_4_hierachical_models.py) then [tutorial_5_expectation_propagation.py](scripts/chapter_3_graphical_models/tutorial_5_expectation_propagation.py).

Expand Down
2 changes: 1 addition & 1 deletion markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Every page below is the corresponding example script **fully executed**, rendere
- [Tutorial 3: Non Linear Search](chapter_1_introduction/tutorial_3_non_linear_search.md) — from `scripts/chapter_1_introduction/tutorial_3_non_linear_search.py`
- [Tutorial 4: Why Modeling Is Hard](chapter_1_introduction/tutorial_4_why_modeling_is_hard.md) — from `scripts/chapter_1_introduction/tutorial_4_why_modeling_is_hard.py`
- [Tutorial 5: Results And Samples](chapter_1_introduction/tutorial_5_results_and_samples.md) — from `scripts/chapter_1_introduction/tutorial_5_results_and_samples.py`
- [Tutorial 6: Scientific Workflow](chapter_1_introduction/tutorial_6_scientific_workflow.md) — from `scripts/chapter_1_introduction/tutorial_6_scientific_workflow.py`
- [Tutorial 8: Scientific Workflow](chapter_1_introduction/tutorial_8_scientific_workflow.md) — from `scripts/chapter_1_introduction/tutorial_8_scientific_workflow.py`

These pages are regenerated manually by PyAutoHands's `generate_markdown.py` when a curated script changes.
2 changes: 1 addition & 1 deletion markdown/chapter_1_introduction/start_here.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interpretation. The chapter includes:

`tutorial_5_results_and_samples.py`: Interpreting model-fit results and using the samples for scientific analysis.

`tutorial_6_scientific_workflow.py`: A short, prose-only introduction to organizing and comparing many model fits,
`tutorial_8_scientific_workflow.py`: A short, prose-only introduction to organizing and comparing many model fits,
with links to the scientific workflow guide and workspace example.

An applied astronomy-focused example (previously tutorial 8) now lives in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
> ✏️ **This page is auto-generated from [`scripts/chapter_1_introduction/tutorial_6_scientific_workflow.py`](../../scripts/chapter_1_introduction/tutorial_6_scientific_workflow.py) — do not edit it directly.**
> ✏️ **This page is auto-generated from [`scripts/chapter_1_introduction/tutorial_8_scientific_workflow.py`](../../scripts/chapter_1_introduction/tutorial_8_scientific_workflow.py) — do not edit it directly.**
> It shows the example fully executed, with its real output images.
> Run it yourself via the [Python script](../../scripts/chapter_1_introduction/tutorial_6_scientific_workflow.py) or the [Jupyter notebook](../../notebooks/chapter_1_introduction/tutorial_6_scientific_workflow.ipynb).
> Run it yourself via the [Python script](../../scripts/chapter_1_introduction/tutorial_8_scientific_workflow.py) or the [Jupyter notebook](../../notebooks/chapter_1_introduction/tutorial_8_scientific_workflow.ipynb).

Tutorial 6: Scientific Workflow
==============================
Tutorial 8: Scientific Workflow
===============================

You can now compose a model, fit it to data and interpret its results. A scientific study often repeats
these steps for many datasets, competing models and different non-linear searches. The next challenge is
Expand Down
4 changes: 3 additions & 1 deletion notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The `scripts` folder contains **HowToFit** lectures, which teach a new user how

# Folders

- `chapter_1_introduction`: Introduction lectures describing how to compose and fit models in **PyAutoFit**, ending with a prose-only introduction to scientific workflows.
- `chapter_1_introduction`: Introduction lectures describing how to compose and fit models in **PyAutoFit**, use gradients to fit them more efficiently and handle the details that make a fit succeed or fail, ending with a prose-only introduction to scientific workflows and an optional tutorial on the Bayesian formalism.
- `chapter_3_graphical_models`: How to compose and fit graphical models which fit many datasets simultaneously, including hierarchical models and Expectation Propagation.
- `simulators`: Simulator scripts that generate the tutorial 1D datasets at runtime.

Expand Down Expand Up @@ -55,6 +55,8 @@ able to:
4. Fit a model to data using a non-linear search.
5. Compose and fit more complex models using **PyAutoFit**'s model composition API.
6. Analyse the results of a model-fit, including parameter estimates and errors.
7. Use gradients of the log likelihood, computed with JAX automatic differentiation, to fit models with gradient based searches.
8. Recognise and fix the details that make a fit fail: degenerate parameterizations, plateaus, clipping and NaNs, and the unit cube.

# Overview of Chapter 3 (Advanced)

Expand Down
8 changes: 7 additions & 1 deletion notebooks/chapter_1_introduction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ The chapter contains the following tutorials:

- [Tutorial 5: Results and Samples](https://colab.research.google.com/github/PyAutoLabs/HowToFit/blob/2026.9.8.1/notebooks/chapter_1_introduction/tutorial_5_results_and_samples.ipynb) — Interpreting model-fit results and using the samples for scientific analysis.

- [Tutorial 6: Scientific Workflow](../../notebooks/chapter_1_introduction/tutorial_6_scientific_workflow.ipynb) — A prose-only introduction to organizing and comparing many fits, with links to the full guide and workspace example.
- [Tutorial 6: Gradients](../../notebooks/chapter_1_introduction/tutorial_6_gradients.ipynb) — How gradients tell a search which way is up, JAX autodiff, and how gradients change MLE, MCMC and nested sampling.

- [Tutorial 7: The Details](../../notebooks/chapter_1_introduction/tutorial_7_the_details.ipynb) — Parameterization, plateaus, assertions, clipping, NaN diagnostics and the unit cube — the details that decide whether a fit converges.

- [Tutorial 8: Scientific Workflow](../../notebooks/chapter_1_introduction/tutorial_8_scientific_workflow.ipynb) — A prose-only introduction to organizing and comparing many fits, with links to the full guide and workspace example.

- [Tutorial Optional: Bayesian Formalism](../../notebooks/chapter_1_introduction/tutorial_optional_bayesian_formalism.ipynb) — How everything in chapter 1 maps onto Bayes' theorem.
15 changes: 12 additions & 3 deletions notebooks/chapter_1_introduction/start_here.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"\n",
"The HowToFit lectures cover an introductory chapter and an advanced chapter:\n",
"\n",
"**Chapter 1: Introduction**: How to fit a model to data, perform statistical inference, and interpret the results\n",
"for scientific analysis, ending with an introduction to scientific workflows.\n",
"**Chapter 1: Introduction**: How to fit a model to data, perform statistical inference, interpret the results\n",
"for scientific analysis and use gradients to fit models more efficiently, ending with an introduction to\n",
"scientific workflows.\n",
"\n",
"**Chapter 3: Graphical Models**: Simultaneous model fitting of large datasets, scaling up to models with tens of\n",
"thousands of parameters.\n",
Expand All @@ -50,9 +51,17 @@
"\n",
"`tutorial_5_results_and_samples.py`: Interpreting model-fit results and using the samples for scientific analysis.\n",
"\n",
"`tutorial_6_scientific_workflow.py`: A short, prose-only introduction to organizing and comparing many model fits,\n",
"`tutorial_6_gradients.py`: How gradients tell a search which way is up, JAX autodiff, and how gradients change\n",
"MLE, MCMC and nested sampling.\n",
"\n",
"`tutorial_7_the_details.py`: Parameterization, plateaus, assertions, clipping, NaN diagnostics and the unit cube,\n",
"the details that decide whether a fit converges.\n",
"\n",
"`tutorial_8_scientific_workflow.py`: A short, prose-only introduction to organizing and comparing many model fits,\n",
"with links to the scientific workflow guide and workspace example.\n",
"\n",
"`tutorial_optional_bayesian_formalism.py`: How everything in chapter 1 maps onto Bayes' theorem.\n",
"\n",
"An applied astronomy-focused example (previously tutorial 8) now lives in\n",
"`autofit_workspace_developer/scripts/howtofit/chapter_1_introduction/tutorial_8_astronomy_example.py`,\n",
"alongside the larger `autofit_workspace_developer/projects/cosmology/` example. These depend on astronomy-specific datasets\n",
Expand Down
Loading
Loading