From 6f335b239f9927f01c0ecfede04f7f4843aa600f Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 14 Sep 2026 22:06:49 +0100 Subject: [PATCH 1/2] docs: fix HowToFit tutorials 1-3 data figure, math rendering and MLE init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tutorial 1 opens the Model Parameterization section with the 1D Gaussian dataset it describes β€” the errorbar figure, then the equation, then the `Where:` list, matching the RTD `python_api` page β€” loaded with the same auto-simulation guard tutorials 2 and 3 use. The model-figure "identical composition" paragraph takes the reader's wording, and the Extensibility section now closes with a worked 18-parameter model (x2 `Gaussian` + x4 `Exponential`) showing `model.info` and the figure and nothing else. Tutorials 1-3 move display and inline math off `\[ \]` / `\( \)`, which Jupyter and Colab do not typeset, onto `$$ $$` / `$ $`, which they do. Tutorial 3's MLE initialisation was wired to a model that was thrown away: `af.InitializerParamStartPoints` was keyed on one `af.Model(Gaussian)` and `search.fit` was then handed a freshly constructed one, so the keys matched nothing, PyAutoFit fell back to random draws, and the fit the prose promises would succeed did not. The model is now built before the initializer and the same object is fitted; the same bug is fixed in the MCMC `InitializerParamBounds` block. Start points move to 52 / 23 / 9 against a truth of 50 / 25 / 10, recovering 49.889 / 25.147 / 9.847 at log likelihood 176.83, deterministic over six runs. The first, deliberately uninitialised MLE fit still fails, as the tutorial teaches. Also: parameter names in the prose now match the classes (`centre`, `normalization`, `sigma`, `rate`), `af.Model` / `Model` / `Gaussian` / `paths` are backticked where they are code, the MLE and Emcee plot titles no longer say Dynesty, and ~20 typos are fixed. Closes #57 Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_0132v5TNVbbvBBESAefHwnwG --- .../tutorial_1_models.ipynb | 160 +++++++++++++++--- .../tutorial_2_fitting_data.ipynb | 32 ++-- .../tutorial_3_non_linear_search.ipynb | 83 +++++---- .../tutorial_1_models.py | 127 +++++++++++--- .../tutorial_2_fitting_data.py | 32 ++-- .../tutorial_3_non_linear_search.py | 81 +++++---- 6 files changed, 364 insertions(+), 151 deletions(-) diff --git a/notebooks/chapter_1_introduction/tutorial_1_models.ipynb b/notebooks/chapter_1_introduction/tutorial_1_models.ipynb index d1af121..7c1a7c8 100644 --- a/notebooks/chapter_1_introduction/tutorial_1_models.ipynb +++ b/notebooks/chapter_1_introduction/tutorial_1_models.ipynb @@ -61,7 +61,7 @@ "This tutorial is split into the following sections:\n", "\n", "- **Paths**: Setting up the working directory path so the tutorial runs correctly on your computer.\n", - "- **Model Parameterization**: An example of how a model is parameterized and is made up of free parameters.\n", + "- **Model Parameterization**: The 1D dataset our model describes and an example of how a model is parameterized and is made up of free parameters.\n", "- **Model Composition**: Composing a model using PyAutoFit's model composition API.\n", "- **Model Creation**: Creating an instance of the model using PyAutoFit's `Model` python object.\n", "- **Model Mapping**: Mapping an input vector of parameters to the model to create an instance of the model.\n", @@ -121,6 +121,7 @@ "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", + "from os import path\n", "\n", "import autofit as af" ], @@ -144,16 +145,82 @@ "\n", "If you don't have a HowToFit clone, you can download it here:\n", " \n", - " https://github.com/PyAutoLabs/autofit_workspace\n", + " https://github.com/PyAutoLabs/HowToFit\n", "\n", "__Model Parameterization__\n", "\n", "A model is a set of equations, numerical processes, and assumptions that describe a physical system and dataset.\n", "\n", - "In this example, our model is one or more 1-dimensional Gaussians, defined by the following equation:\n", + "In this example, our model is one or more 1-dimensional Gaussians, which describe the dataset plotted below: a \n", + "noisy 1D signal, shown in black with error bars given by its noise-map." + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "dataset_path = path.join(\"dataset\", \"example_1d\", \"gaussian_x1\")" + ], + "outputs": [], + "execution_count": null + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "__Dataset Auto-Simulation__\n", + "\n", + "If the dataset does not already exist on your system, it will be created by running the corresponding\n", + "simulator script. This ensures that all example scripts can be run without manually simulating data first." + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "if not path.exists(dataset_path):\n", + " import subprocess\n", + " import sys\n", + "\n", + " subprocess.run(\n", + " [sys.executable, \"scripts/simulators/simulators.py\"],\n", + " check=True,\n", + " )\n", + "\n", + "data = af.util.numpy_array_from_json(file_path=path.join(dataset_path, \"data.json\"))\n", + "noise_map = af.util.numpy_array_from_json(\n", + " file_path=path.join(dataset_path, \"noise_map.json\")\n", + ")\n", + "\n", + "xvalues = np.arange(data.shape[0])\n", + "\n", + "plt.errorbar(\n", + " xvalues,\n", + " data,\n", + " yerr=noise_map,\n", + " linestyle=\"\",\n", + " color=\"k\",\n", + " ecolor=\"k\",\n", + " elinewidth=1,\n", + " capsize=2,\n", + ")\n", + "plt.title(\"1D Gaussian dataset.\")\n", + "plt.xlabel(\"x values of profile\")\n", + "plt.ylabel(\"Profile Normalization\")\n", + "plt.show()\n", + "plt.clf()" + ], + "outputs": [], + "execution_count": null + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The 1D signal above was generated using a 1D Gaussian profile of the form:\n", "\n", "\\begin{equation*}\n", - "g(x, I, \\sigma) = \\frac{N}{\\sigma\\sqrt{2\\pi}} \\exp{(-0.5 (x / \\sigma)^2)}\n", + "g(x, N, \\sigma) = \\frac{N}{\\sigma\\sqrt{2\\pi}} \\exp{(-0.5 (x / \\sigma)^2)}\n", "\\end{equation*}\n", "\n", "Where:\n", @@ -162,15 +229,16 @@ "\n", "- `N`: The overall normalization of the Gaussian.\n", "\n", - "\n", - "- `\\sigma`: The size of the Gaussian (Full Width Half Maximum, $\\mathrm{FWHM}$, is $2{\\sqrt{2\\ln 2}}\\;\\sigma$).\n", + "- $\\sigma$: The size of the Gaussian (Full Width Half Maximum, $\\mathrm{FWHM}$, is $2{\\sqrt{2\\ln 2}}\\;\\sigma$).\n", "\n", "While a 1D Gaussian might seem like a rudimentary model, it has many real-world applications in signal processing. \n", "For example, 1D Gaussians are fitted to datasets to measure the size of an observed signal. Thus, this model has \n", "practical real-world applications.\n", "\n", - "We now have a model, expressed as a simple 1D Gaussian. The model has three parameters, $(x, N, \\sigma)$. Using \n", - "different combinations of these parameters creates different realizations of the model, which we illustrate below.\n", + "We now have a model, expressed as a simple 1D Gaussian. Note that `x` is not a free parameter: it is the coordinate \n", + "the equation is evaluated at. The three free parameters are the centre of the Gaussian, $N$ and $\\sigma$, which the \n", + "`Gaussian` class written below calls `centre`, `normalization` and `sigma`. Using different combinations of these \n", + "parameters creates different realizations of the model, which we illustrate below.\n", "\n", "__Model Composition__\n", "\n", @@ -257,15 +325,15 @@ "- The default values and typing of the input arguments define whether a parameter is a single-valued float or a \n", "multi-valued tuple. For the `Gaussian` class above, no input parameters are tuples, but later examples use tuples.\n", "\n", - "- It includes functions associated with that model component, specifically the model_data function. When we create \n", - "instances of a `Gaussian` below, this function is used to generate a 1D representation of it as a NumPy array.\n", + "- It includes functions associated with that model component, specifically the `model_data_from` function. When we \n", + "create instances of a `Gaussian` below, this function is used to generate a 1D representation of it as a NumPy array.\n", "\n", "__Model Creation__\n", "\n", "The `Gaussian` class above is a standard Python class. It does not yet act as a model component that can be used\n", "for model fitting with PyAutoFit.\n", "\n", - "To transform the Gaussian class into a model component that can be used for model fitting with PyAutoFit, we use \n", + "To transform the `Gaussian` class into a model component that can be used for model fitting with PyAutoFit, we use \n", "the `af.Model` object. This tells PyAutoFit to treat the input Python class as a model component." ] }, @@ -284,7 +352,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In PyAutoFit, a Model object encapsulates a model component that can be used for model fitting. It provides several \n", + "In PyAutoFit, a `Model` object encapsulates a model component that can be used for model fitting. It provides several \n", "attributes that describe the model component, such as the `total_free_parameters` attribute, which indicates the \n", "number of free parameters in the model:" ] @@ -354,14 +422,14 @@ "source": [ "__Model Mapping__\n", "\n", - "In PyAutoFit, instances of model components created via the af.Model object can be instantiated by mapping an input \n", + "In PyAutoFit, instances of model components created via the `af.Model` object can be instantiated by mapping an input \n", "vector of parameters to the Python class that the model object represents. The order of parameters in the model is \n", "crucial for correctly defining the input vector.\n", "\n", - "To determine the order of parameters in the model, PyAutoFit provides the paths attribute of the model object. \n", + "To determine the order of parameters in the model, PyAutoFit provides the `paths` attribute of the model object. \n", "This attribute contains information about the parameter paths within the model.\n", "\n", - "Here's how you can access the paths attribute to understand the order of parameters in the model:" + "Here's how you can access the `paths` attribute to understand the order of parameters in the model:" ] }, { @@ -377,8 +445,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To create an instance of the Gaussian model component using PyAutoFit, following the order of parameters defined by \n", - "the paths attribute (`centre`, `normalization`, and `sigma`), you can initialize the instance as follows:" + "To create an instance of the `Gaussian` model component using PyAutoFit, following the order of parameters defined by \n", + "the `paths` attribute (`centre`, `normalization`, and `sigma`), you can initialize the instance as follows:" ] }, { @@ -419,7 +487,7 @@ "metadata": {}, "source": [ "print(\"Instance Parameters \\n\")\n", - "print(\"x = \", instance.centre)\n", + "print(\"centre = \", instance.centre)\n", "print(\"normalization = \", instance.normalization)\n", "print(\"sigma = \", instance.sigma)" ], @@ -481,7 +549,7 @@ "component and another 1D profile, an `Exponential`, defined by the equation:\n", "\n", "\\begin{equation*}\n", - "g(x, I, \\lambda) = N \\lambda \\exp{- \\lambda x }\n", + "g(x, N, \\lambda) = N \\lambda \\exp{- \\lambda x }\n", "\\end{equation*}\n", "\n", "where:\n", @@ -520,8 +588,8 @@ " The x coordinate of the profile centre.\n", " normalization\n", " Overall normalization of the profile.\n", - " ratw\n", - " The decay rate controlling has fast the Exponential declines.\n", + " rate\n", + " The decay rate controlling how fast the Exponential declines.\n", " \"\"\"\n", " self.centre = centre\n", " self.normalization = normalization\n", @@ -529,7 +597,7 @@ "\n", " def model_data_from(self, xvalues: np.ndarray):\n", " \"\"\"\n", - " Returns a 1D Gaussian on an input list of Cartesian x coordinates.\n", + " Returns a 1D Exponential on an input list of Cartesian x coordinates.\n", "\n", " The input xvalues are translated to a coordinate system centred on the `Exponential`, via its `centre`.\n", "\n", @@ -540,6 +608,11 @@ " ----------\n", " xvalues\n", " The x coordinates in the original reference frame of the data.\n", + "\n", + " Returns\n", + " -------\n", + " np.array\n", + " The Exponential values at the input x coordinates.\n", " \"\"\"\n", " transformed_xvalues = np.subtract(xvalues, self.centre)\n", " return self.normalization * np.multiply(\n", @@ -639,8 +712,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The two ways of writing the composition look different on the page, but they build exactly the same model, with the\n", - "same components and the same free parameters." + "The figure is identical to the previous example, because both ways of writing the model produce the same model \n", + "structure.\n", + "\n", + "This is a useful check when composing models in different ways: if the figure looks the same, the underlying structure \n", + "of the model is the same too. Any differences between the fits must therefore come from details such as the parameter \n", + "priors or fixed values, rather than how the model is composed." ] }, { @@ -704,12 +781,12 @@ "metadata": {}, "source": [ "print(\"Instance Parameters \\n\")\n", - "print(\"x (Gaussian) = \", instance.gaussian.centre)\n", + "print(\"centre (Gaussian) = \", instance.gaussian.centre)\n", "print(\"normalization (Gaussian) = \", instance.gaussian.normalization)\n", "print(\"sigma (Gaussian) = \", instance.gaussian.sigma)\n", - "print(\"x (Exponential) = \", instance.exponential.centre)\n", + "print(\"centre (Exponential) = \", instance.exponential.centre)\n", "print(\"normalization (Exponential) = \", instance.exponential.normalization)\n", - "print(\"sigma (Exponential) = \", instance.exponential.rate)" + "print(\"rate (Exponential) = \", instance.exponential.rate)" ], "outputs": [], "execution_count": null @@ -892,6 +969,35 @@ "\n", "These objects serve numerous other essential purposes that we will explore in subsequent tutorials.\n", "\n", + "To see this extensibility in action, the model below is composed of two `Gaussian`'s and four `Exponential`'s. Each \n", + "component has 3 free parameters, meaning this model has 18 free parameters in total, but composing it requires just \n", + "a handful of extra lines of code:" + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "model = af.Collection(\n", + " gaussian_0=Gaussian,\n", + " gaussian_1=Gaussian,\n", + " exponential_0=Exponential,\n", + " exponential_1=Exponential,\n", + " exponential_2=Exponential,\n", + " exponential_3=Exponential,\n", + ")\n", + "\n", + "print(model.info)\n", + "\n", + "af.ModelPlotter(model).figure()" + ], + "outputs": [], + "execution_count": null + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "**PyAutoFit** offers a comprehensive API for building models, which includes models constructed using NumPy arrays, \n", "hierarchies of Python classes, and graphical models where parameters are interconnected. These advanced modeling \n", "techniques are gradually introduced throughout the HowToFit lectures.\n", diff --git a/notebooks/chapter_1_introduction/tutorial_2_fitting_data.ipynb b/notebooks/chapter_1_introduction/tutorial_2_fitting_data.ipynb index 6a96df9..3b2d084 100644 --- a/notebooks/chapter_1_introduction/tutorial_2_fitting_data.ipynb +++ b/notebooks/chapter_1_introduction/tutorial_2_fitting_data.ipynb @@ -405,7 +405,7 @@ "We can plot the residuals with error bars based on the noise map. The plot below reveals that the model is a poor fit, \n", "as many residuals deviate significantly from zero even after accounting for the noise in each data point.\n", "\n", - "A blue line through zero is included on the plot, to make it clear where residuals are not constent with zero\n", + "A blue line through zero is included on the plot, to make it clear where residuals are not consistent with zero\n", "above the noise level." ] }, @@ -445,7 +445,9 @@ "\n", "The normalized residual map is computed as the residual map divided by the noise map:\n", "\n", - "\\[ \\text{normalized\\_residual} = \\frac{\\text{residual\\_map}}{\\text{noise\\_map}} = \\frac{\\text{data} - \\text{model\\_data}}{\\text{noise\\_map}} \\]\n", + "$$\n", + "\\text{normalized\\_residual} = \\frac{\\text{residual\\_map}}{\\text{noise\\_map}} = \\frac{\\text{data} - \\text{model\\_data}}{\\text{noise\\_map}}\n", + "$$\n", "\n", "If you're familiar with the concept of standard deviations (sigma) in statistics, the normalized residual map represents \n", "how many standard deviations the residual is from zero. For instance, a normalized residual of 2.0 (corresponding \n", @@ -482,7 +484,9 @@ "\n", "The chi-squared map is calculated as:\n", "\n", - "\\[ \\chi^2 = \\left(\\frac{\\text{data} - \\text{model\\_data}}{\\text{noise\\_map}}\\right)^2 \\]\n", + "$$\n", + "\\chi^2 = \\left(\\frac{\\text{data} - \\text{model\\_data}}{\\text{noise\\_map}}\\right)^2\n", + "$$\n", "\n", "The purpose of squaring the normalized residual map is to ensure all values are positive. For instance, both a \n", "normalized residual of -0.2 and 0.2 would square to 0.04, indicating the same level of fit in terms of `chi_squared`.\n", @@ -514,7 +518,9 @@ "\n", "It is defined as the sum of all values in the `chi_squared_map` and is computed as:\n", "\n", - "\\[ \\chi^2 = \\sum \\left(\\frac{\\text{data} - \\text{model\\_data}}{\\text{noise\\_map}}\\right)^2 \\]\n", + "$$\n", + "\\chi^2 = \\sum \\left(\\frac{\\text{data} - \\text{model\\_data}}{\\text{noise\\_map}}\\right)^2\n", + "$$\n", "\n", "This summing process highlights why ensuring all values in the chi-squared map are positive is crucial. If we \n", "didn't square the values (making them positive), positive and negative residuals would cancel each other out, \n", @@ -545,9 +551,9 @@ "\n", "The `noise_normalization` is computed as the logarithm of the sum of squared noise values in our data: \n", "\n", - "\\[\n", - "\\text{{noise\\_normalization}} = \\sum \\log(2 \\pi \\text{{noise\\_map}}^2)\n", - "\\]\n", + "$$\n", + "\\text{noise\\_normalization} = \\sum \\log(2 \\pi \\text{noise\\_map}^2)\n", + "$$\n", "\n", "This quantity is fixed because the noise-map remains constant throughout the fitting process. Despite this, \n", "including the `noise_normalization` is considered good practice due to its statistical significance.\n", @@ -578,7 +584,9 @@ "This measure is calculated by taking the sum of the `chi_squared` and `noise_normalization`, and then multiplying the \n", "result by -0.5:\n", "\n", - "\\[ \\text{log\\_likelihood} = -0.5 \\times \\left( \\chi^2 + \\text{noise\\_normalization} \\right) \\]\n", + "$$\n", + "\\text{log\\_likelihood} = -0.5 \\times \\left( \\chi^2 + \\text{noise\\_normalization} \\right)\n", + "$$\n", "\n", "Why multiply by -0.5? The exact rationale behind this factor isn't critical for our current understanding." ] @@ -733,7 +741,7 @@ "\n", "The first guess correctly pinpoints that the Gaussian's peak is at 50.0, but the width and normalization are off.\n", "\n", - "The `log_likelihood` is computed and printed, however because we don't have a value to compare it to yet, its hard\n", + "The `log_likelihood` is computed and printed, however because we don't have a value to compare it to yet, it's hard\n", "to assess if it is a large or small value." ] }, @@ -766,7 +774,7 @@ "source": [ "__Guess 2__\n", "\n", - "The second guess refines the width and normalization, but the size of the Gaussian is still off.\n", + "The second guess refines the normalization, but the width of the Gaussian is still off.\n", "\n", "The `log_likelihood` is computed and printed, and increases a lot compared to the previous guess, indicating that\n", "the fit is better." @@ -912,8 +920,8 @@ "data? A residual map shows the differences between observed data and the model's predictions, often revealing \n", "patterns or areas where the model fits well or poorly.\n", "\n", - "Furthermore, can you foresee how you would calculate a log likelihood from this residual map? The log likelihood q\n", - "uantifies how well your model fits the data, incorporating both the residual values and the noise characteristics of \n", + "Furthermore, can you foresee how you would calculate a log likelihood from this residual map? The log likelihood \n", + "quantifies how well your model fits the data, incorporating both the residual values and the noise characteristics of \n", "your observations.\n", "\n", "If you find it challenging to visualize these aspects right now, that's perfectly fine. The first step is to \n", diff --git a/notebooks/chapter_1_introduction/tutorial_3_non_linear_search.ipynb b/notebooks/chapter_1_introduction/tutorial_3_non_linear_search.ipynb index 1b57dad..1a47b47 100644 --- a/notebooks/chapter_1_introduction/tutorial_3_non_linear_search.ipynb +++ b/notebooks/chapter_1_introduction/tutorial_3_non_linear_search.ipynb @@ -31,7 +31,7 @@ " model instance to the data.\n", "\n", "- Fit a 1D Gaussian model to 1D data with different non-linear searches, including a maximum likelihood estimator (MLE),\n", - " Markok Chain Monte Carlo (MCMC) and nested sampling.\n", + " Markov Chain Monte Carlo (MCMC) and nested sampling.\n", "\n", "All these steps utilize **PyAutoFit**'s API for model-fitting.\n", "\n", @@ -60,29 +60,34 @@ "\n", "For example, consider a simple function:\n", "\n", - "\\[ f(x) = x^2 \\]\n", + "$$\n", + "f(x) = x^2\n", + "$$\n", "\n", - "Here, \\( x \\) is the parameter input into the function \\( f \\), and \\( f(x) \\) returns \\( x^2 \\). This\n", - "mapping between \\( x \\) and \\( f(x) \\) defines the \"parameter space\" of the function, which in this case is a parabola.\n", + "Here, $x$ is the parameter input into the function $f$, and $f(x)$ returns $x^2$. This\n", + "mapping between $x$ and $f(x)$ defines the \"parameter space\" of the function, which in this case is a parabola.\n", "\n", - "Functions can have multiple parameters, such as \\( x \\), \\( y \\), and \\( z \\):\n", + "Functions can have multiple parameters, such as $x$, $y$, and $z$:\n", "\n", - "\\[ f(x, y, z) = x + y^2 - z^3 \\]\n", + "$$\n", + "f(x, y, z) = x + y^2 - z^3\n", + "$$\n", "\n", - "Here, the mapping between \\( x \\), \\( y \\), \\( z \\), and \\( f(x, y, z) \\) defines a parameter space with three\n", + "Here, the mapping between $x$, $y$, $z$, and $f(x, y, z)$ defines a parameter space with three\n", "dimensions.\n", "\n", "This concept of a parameter space relates closely to how we define and use instances of models in model-fitting.\n", "For instance, in our previous tutorial, we used instances of a 1D Gaussian profile with\n", - "parameters \\( (x, I, \\sigma) \\) to fit data and compute a log likelihood.\n", + "parameters $(\\mathrm{centre}, N, \\sigma)$ to fit data and compute a log likelihood.\n", "\n", - "This process can be thought of as complete analogous to a function \\( f(x, y, z) \\), where the output value is the\n", + "This process can be thought of as completely analogous to a function $f(x, y, z)$, where the output value is the\n", "log likelihood. This key function, which maps parameter values to a log likelihood, is called the \"likelihood function\"\n", "in statistical inference, albeit we will refer to it hereafter as the `log_likelihood_function` to be explicit\n", "that it is the log of the likelihood function.\n", "\n", "By expressing the likelihood in this manner, we can consider our model as having a parameter space -\u2014 a\n", - "multidimensional surface that spans all possible values of the model parameters \\( x, I, \\sigma \\).\n", + "multidimensional surface that spans all possible values of the model parameters $\\mathrm{centre}$, $N$ and $\\sigma$\n", + "(the `centre`, `normalization` and `sigma` of the `Gaussian` class).\n", "\n", "This surface is often referred to as the \"likelihood surface\", and our objective during model-fitting is to find\n", "its peak.\n", @@ -137,7 +142,7 @@ "\n", "__Deeper Background__\n", "\n", - "**The descriptions of how searches work in this example are simplfied and phoenomenological and do not give a full\n", + "**The descriptions of how searches work in this example are simplified and phenomenological and do not give a full\n", "description of how they work at a deep statistical level. The goal is to provide you with an intuition for how to use\n", "them and when different searches are appropriate for different problems. Later tutorials will provide a more formal\n", "description of how these searches work.**\n", @@ -446,10 +451,10 @@ " parameters, fits the observed data. \n", "\n", "**Interface with Non-linear Search:** The `log_likelihood_function` is repeatedly called by the non-linear search \n", - " algorithm to assess the goodness of fit of different parameter combinations. The search algorithm call this function\n", + " algorithm to assess the goodness of fit of different parameter combinations. The search algorithm calls this function\n", " many times and maps out regions of parameter space that yield high likelihood solutions.\n", " \n", - "Below is a suitable `Analysis` class for fitting a 1D gaussian to the data loaded above." + "Below is a suitable `Analysis` class for fitting a 1D Gaussian to the data loaded above." ] }, { @@ -597,7 +602,7 @@ "print(\n", " \"\"\"\n", " The non-linear search has begun running.\n", - " This Jupyter notebook cell with progress once the search has completed - this could take a few minutes!\n", + " This Jupyter notebook cell will progress once the search has completed - this could take a few minutes!\n", " \"\"\"\n", ")\n", "\n", @@ -605,7 +610,7 @@ "\n", "result = search.fit(model=model, analysis=analysis)\n", "\n", - "print(\"The search has finished run - you may now continue the notebook.\")" + "print(\"The search has finished running - you may now continue the notebook.\")" ], "outputs": [], "execution_count": null @@ -618,7 +623,7 @@ "\n", "The `info` attribute shows the result in a readable format.\n", "\n", - "[Above, we discussed that the `info_whitespace_length` parameter in the config files could b changed to make \n", + "[Above, we discussed that the `info_whitespace_length` parameter in the config files could be changed to make \n", "the `model.info` attribute display optimally on your computer. This attribute also controls the whitespace of the\n", "`result.info` attribute.]" ] @@ -678,7 +683,7 @@ " capsize=2,\n", ")\n", "plt.plot(xvalues, model_data, color=\"r\")\n", - "plt.title(\"Dynesty model fit to 1D Gaussian dataset.\")\n", + "plt.title(\"LBFGS model fit to 1D Gaussian dataset.\")\n", "plt.xlabel(\"x values of profile\")\n", "plt.ylabel(\"Profile normalization\")\n", "plt.show()\n", @@ -699,18 +704,24 @@ "\n", "To achieve a better fit with MLE, the search needs to begin in a region of parameter space where the log likelihood \n", "is higher. This process is known as \"initialization,\" and it involves providing the search with an \n", - "appropriate \"starting point\" in parameter space." + "appropriate \"starting point\" in parameter space.\n", + "\n", + "The starting point is defined per parameter, so we create the model first and use its parameters as the keys of \n", + "the initializer. The values below are a deliberately imperfect guess at the true solution (`centre=50.0`, \n", + "`normalization=25.0`, `sigma=10.0`), but they are close enough for the search to climb the likelihood gradient to it." ] }, { "cell_type": "code", "metadata": {}, "source": [ + "model = af.Model(Gaussian)\n", + "\n", "initializer = af.InitializerParamStartPoints(\n", " {\n", - " model.centre: 55.0,\n", - " model.normalization: 20.0,\n", - " model.sigma: 8.0,\n", + " model.centre: 52.0,\n", + " model.normalization: 23.0,\n", + " model.sigma: 9.0,\n", " }\n", ")\n", "\n", @@ -719,15 +730,13 @@ "print(\n", " \"\"\"\n", " The non-linear search has begun running.\n", - " This Jupyter notebook cell with progress once the search has completed - this could take a few minutes!\n", + " This Jupyter notebook cell will progress once the search has completed - this could take a few minutes!\n", " \"\"\"\n", ")\n", "\n", - "model = af.Model(Gaussian)\n", - "\n", "result = search.fit(model=model, analysis=analysis)\n", "\n", - "print(\"The search has finished run - you may now continue the notebook.\")" + "print(\"The search has finished running - you may now continue the notebook.\")" ], "outputs": [], "execution_count": null @@ -760,7 +769,7 @@ " capsize=2,\n", ")\n", "plt.plot(xvalues, model_data, color=\"r\")\n", - "plt.title(\"Dynesty model fit to 1D Gaussian dataset.\")\n", + "plt.title(\"LBFGS model fit to 1D Gaussian dataset.\")\n", "plt.xlabel(\"x values of profile\")\n", "plt.ylabel(\"Profile normalization\")\n", "plt.show()\n", @@ -818,7 +827,7 @@ "print(\n", " \"\"\"\n", " The non-linear search has begun running.\n", - " This Jupyter notebook cell with progress once the search has completed - this could take a few minutes!\n", + " This Jupyter notebook cell will progress once the search has completed - this could take a few minutes!\n", " \"\"\"\n", ")\n", "\n", @@ -826,7 +835,7 @@ "\n", "result = search.fit(model=model, analysis=analysis)\n", "\n", - "print(\"The search has finished run - you may now continue the notebook.\")\n", + "print(\"The search has finished running - you may now continue the notebook.\")\n", "\n", "print(result.info)\n", "\n", @@ -844,7 +853,7 @@ " capsize=2,\n", ")\n", "plt.plot(xvalues, model_data, color=\"r\")\n", - "plt.title(\"Dynesty model fit to 1D Gaussian dataset.\")\n", + "plt.title(\"Emcee model fit to 1D Gaussian dataset.\")\n", "plt.xlabel(\"x values of profile\")\n", "plt.ylabel(\"Profile normalization\")\n", "plt.show()\n", @@ -880,6 +889,8 @@ "cell_type": "code", "metadata": {}, "source": [ + "model = af.Model(Gaussian)\n", + "\n", "initializer = af.InitializerParamBounds(\n", " {\n", " model.centre: (54.0, 56.0),\n", @@ -896,15 +907,13 @@ "print(\n", " \"\"\"\n", " The non-linear search has begun running.\n", - " This Jupyter notebook cell with progress once the search has completed - this could take a few minutes!\n", + " This Jupyter notebook cell will progress once the search has completed - this could take a few minutes!\n", " \"\"\"\n", ")\n", "\n", - "model = af.Model(Gaussian)\n", - "\n", "result = search.fit(model=model, analysis=analysis)\n", "\n", - "print(\"The search has finished run - you may now continue the notebook.\")\n", + "print(\"The search has finished running - you may now continue the notebook.\")\n", "\n", "print(result.info)" ], @@ -925,7 +934,7 @@ "used. One often ends up having to perform \"trial and error\" to verify a sufficient number of steps are used.\n", "\n", "MCMC can perform badly in parameter spaces with certain types of complexity, for example when there are\n", - "are local maxima \"peaks\" the walkers can become stuck walking around them.\n", + "local maxima \"peaks\" the walkers can become stuck walking around them.\n", "\n", "__Nested Sampling__\n", "\n", @@ -974,7 +983,7 @@ "print(\n", " \"\"\"\n", " The non-linear search has begun running.\n", - " This Jupyter notebook cell with progress once the search has completed - this could take a few minutes!\n", + " This Jupyter notebook cell will progress once the search has completed - this could take a few minutes!\n", " \"\"\"\n", ")\n", "\n", @@ -982,7 +991,7 @@ "\n", "result = search.fit(model=model, analysis=analysis)\n", "\n", - "print(\"The search has finished run - you may now continue the notebook.\")\n", + "print(\"The search has finished running - you may now continue the notebook.\")\n", "\n", "print(result.info)\n", "\n", @@ -1019,7 +1028,7 @@ "specify the number of steps the search should take. \n", "\n", "This method also excels in handling complex parameter spaces, particularly those with multiple peaks. This is because\n", - "the live points will identify each peak and converge around them, but then begin to be discard from a peak if higher\n", + "the live points will identify each peak and converge around them, but then begin to be discarded from a peak if higher\n", "likelihood points are found elsewhere in parameter space. In MCMC, the walkers can get stuck indefinitely around a\n", "peak, causing the method to stall.\n", "\n", diff --git a/scripts/chapter_1_introduction/tutorial_1_models.py b/scripts/chapter_1_introduction/tutorial_1_models.py index e7e8758..1b37acd 100644 --- a/scripts/chapter_1_introduction/tutorial_1_models.py +++ b/scripts/chapter_1_introduction/tutorial_1_models.py @@ -56,7 +56,7 @@ This tutorial is split into the following sections: - **Paths**: Setting up the working directory path so the tutorial runs correctly on your computer. -- **Model Parameterization**: An example of how a model is parameterized and is made up of free parameters. +- **Model Parameterization**: The 1D dataset our model describes and an example of how a model is parameterized and is made up of free parameters. - **Model Composition**: Composing a model using PyAutoFit's model composition API. - **Model Creation**: Creating an instance of the model using PyAutoFit's `Model` python object. - **Model Mapping**: Mapping an input vector of parameters to the model to create an instance of the model. @@ -73,6 +73,7 @@ import numpy as np import matplotlib.pyplot as plt +from os import path import autofit as af @@ -90,16 +91,60 @@ If you don't have a HowToFit clone, you can download it here: - https://github.com/PyAutoLabs/autofit_workspace + https://github.com/PyAutoLabs/HowToFit __Model Parameterization__ A model is a set of equations, numerical processes, and assumptions that describe a physical system and dataset. -In this example, our model is one or more 1-dimensional Gaussians, defined by the following equation: +In this example, our model is one or more 1-dimensional Gaussians, which describe the dataset plotted below: a +noisy 1D signal, shown in black with error bars given by its noise-map. +""" +dataset_path = path.join("dataset", "example_1d", "gaussian_x1") + +""" +__Dataset Auto-Simulation__ + +If the dataset does not already exist on your system, it will be created by running the corresponding +simulator script. This ensures that all example scripts can be run without manually simulating data first. +""" +if not path.exists(dataset_path): + import subprocess + import sys + + subprocess.run( + [sys.executable, "scripts/simulators/simulators.py"], + check=True, + ) + +data = af.util.numpy_array_from_json(file_path=path.join(dataset_path, "data.json")) +noise_map = af.util.numpy_array_from_json( + file_path=path.join(dataset_path, "noise_map.json") +) + +xvalues = np.arange(data.shape[0]) + +plt.errorbar( + xvalues, + data, + yerr=noise_map, + linestyle="", + color="k", + ecolor="k", + elinewidth=1, + capsize=2, +) +plt.title("1D Gaussian dataset.") +plt.xlabel("x values of profile") +plt.ylabel("Profile Normalization") +plt.show() +plt.clf() + +r""" +The 1D signal above was generated using a 1D Gaussian profile of the form: \begin{equation*} -g(x, I, \sigma) = \frac{N}{\sigma\sqrt{2\pi}} \exp{(-0.5 (x / \sigma)^2)} +g(x, N, \sigma) = \frac{N}{\sigma\sqrt{2\pi}} \exp{(-0.5 (x / \sigma)^2)} \end{equation*} Where: @@ -108,15 +153,16 @@ - `N`: The overall normalization of the Gaussian. - -- `\sigma`: The size of the Gaussian (Full Width Half Maximum, $\mathrm{FWHM}$, is $2{\sqrt{2\ln 2}}\;\sigma$). +- $\sigma$: The size of the Gaussian (Full Width Half Maximum, $\mathrm{FWHM}$, is $2{\sqrt{2\ln 2}}\;\sigma$). While a 1D Gaussian might seem like a rudimentary model, it has many real-world applications in signal processing. For example, 1D Gaussians are fitted to datasets to measure the size of an observed signal. Thus, this model has practical real-world applications. -We now have a model, expressed as a simple 1D Gaussian. The model has three parameters, $(x, N, \sigma)$. Using -different combinations of these parameters creates different realizations of the model, which we illustrate below. +We now have a model, expressed as a simple 1D Gaussian. Note that `x` is not a free parameter: it is the coordinate +the equation is evaluated at. The three free parameters are the centre of the Gaussian, $N$ and $\sigma$, which the +`Gaussian` class written below calls `centre`, `normalization` and `sigma`. Using different combinations of these +parameters creates different realizations of the model, which we illustrate below. __Model Composition__ @@ -193,15 +239,15 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: - The default values and typing of the input arguments define whether a parameter is a single-valued float or a multi-valued tuple. For the `Gaussian` class above, no input parameters are tuples, but later examples use tuples. -- It includes functions associated with that model component, specifically the model_data function. When we create -instances of a `Gaussian` below, this function is used to generate a 1D representation of it as a NumPy array. +- It includes functions associated with that model component, specifically the `model_data_from` function. When we +create instances of a `Gaussian` below, this function is used to generate a 1D representation of it as a NumPy array. __Model Creation__ The `Gaussian` class above is a standard Python class. It does not yet act as a model component that can be used for model fitting with PyAutoFit. -To transform the Gaussian class into a model component that can be used for model fitting with PyAutoFit, we use +To transform the `Gaussian` class into a model component that can be used for model fitting with PyAutoFit, we use the `af.Model` object. This tells PyAutoFit to treat the input Python class as a model component. """ model = af.Model(Gaussian) @@ -209,7 +255,7 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: print(model) """ -In PyAutoFit, a Model object encapsulates a model component that can be used for model fitting. It provides several +In PyAutoFit, a `Model` object encapsulates a model component that can be used for model fitting. It provides several attributes that describe the model component, such as the `total_free_parameters` attribute, which indicates the number of free parameters in the model: """ @@ -246,20 +292,20 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: """ __Model Mapping__ -In PyAutoFit, instances of model components created via the af.Model object can be instantiated by mapping an input +In PyAutoFit, instances of model components created via the `af.Model` object can be instantiated by mapping an input vector of parameters to the Python class that the model object represents. The order of parameters in the model is crucial for correctly defining the input vector. -To determine the order of parameters in the model, PyAutoFit provides the paths attribute of the model object. +To determine the order of parameters in the model, PyAutoFit provides the `paths` attribute of the model object. This attribute contains information about the parameter paths within the model. -Here's how you can access the paths attribute to understand the order of parameters in the model: +Here's how you can access the `paths` attribute to understand the order of parameters in the model: """ print(model.paths) """ -To create an instance of the Gaussian model component using PyAutoFit, following the order of parameters defined by -the paths attribute (`centre`, `normalization`, and `sigma`), you can initialize the instance as follows: +To create an instance of the `Gaussian` model component using PyAutoFit, following the order of parameters defined by +the `paths` attribute (`centre`, `normalization`, and `sigma`), you can initialize the instance as follows: """ instance = model.instance_from_vector(vector=[30.0, 2.0, 3.0]) @@ -273,7 +319,7 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: It has the parameters of the `Gaussian` with the values input above. """ print("Instance Parameters \n") -print("x = ", instance.centre) +print("centre = ", instance.centre) print("normalization = ", instance.normalization) print("sigma = ", instance.sigma) @@ -318,7 +364,7 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: component and another 1D profile, an `Exponential`, defined by the equation: \begin{equation*} -g(x, I, \lambda) = N \lambda \exp{- \lambda x } +g(x, N, \lambda) = N \lambda \exp{- \lambda x } \end{equation*} where: @@ -352,8 +398,8 @@ def __init__( The x coordinate of the profile centre. normalization Overall normalization of the profile. - ratw - The decay rate controlling has fast the Exponential declines. + rate + The decay rate controlling how fast the Exponential declines. """ self.centre = centre self.normalization = normalization @@ -361,7 +407,7 @@ def __init__( def model_data_from(self, xvalues: np.ndarray): """ - Returns a 1D Gaussian on an input list of Cartesian x coordinates. + Returns a 1D Exponential on an input list of Cartesian x coordinates. The input xvalues are translated to a coordinate system centred on the `Exponential`, via its `centre`. @@ -372,6 +418,11 @@ def model_data_from(self, xvalues: np.ndarray): ---------- xvalues The x coordinates in the original reference frame of the data. + + Returns + ------- + np.array + The Exponential values at the input x coordinates. """ transformed_xvalues = np.subtract(xvalues, self.centre) return self.normalization * np.multiply( @@ -411,8 +462,12 @@ def model_data_from(self, xvalues: np.ndarray): print(model.info) """ -The two ways of writing the composition look different on the page, but they build exactly the same model, with the -same components and the same free parameters. +The figure is identical to the previous example, because both ways of writing the model produce the same model +structure. + +This is a useful check when composing models in different ways: if the figure looks the same, the underlying structure +of the model is the same too. Any differences between the fits must therefore come from details such as the parameter +priors or fixed values, rather than how the model is composed. """ af.ModelPlotter(model).figure() @@ -438,12 +493,12 @@ def model_data_from(self, xvalues: np.ndarray): The argument names input into the `Collection` define the attribute names of the `instance`: """ print("Instance Parameters \n") -print("x (Gaussian) = ", instance.gaussian.centre) +print("centre (Gaussian) = ", instance.gaussian.centre) print("normalization (Gaussian) = ", instance.gaussian.normalization) print("sigma (Gaussian) = ", instance.gaussian.sigma) -print("x (Exponential) = ", instance.exponential.centre) +print("centre (Exponential) = ", instance.exponential.centre) print("normalization (Exponential) = ", instance.exponential.normalization) -print("sigma (Exponential) = ", instance.exponential.rate) +print("rate (Exponential) = ", instance.exponential.rate) """ In the context of the model's equations, it is simply the sum of the equations defining the `Gaussian` @@ -544,6 +599,24 @@ def __init__( These objects serve numerous other essential purposes that we will explore in subsequent tutorials. +To see this extensibility in action, the model below is composed of two `Gaussian`'s and four `Exponential`'s. Each +component has 3 free parameters, meaning this model has 18 free parameters in total, but composing it requires just +a handful of extra lines of code: +""" +model = af.Collection( + gaussian_0=Gaussian, + gaussian_1=Gaussian, + exponential_0=Exponential, + exponential_1=Exponential, + exponential_2=Exponential, + exponential_3=Exponential, +) + +print(model.info) + +af.ModelPlotter(model).figure() + +""" **PyAutoFit** offers a comprehensive API for building models, which includes models constructed using NumPy arrays, hierarchies of Python classes, and graphical models where parameters are interconnected. These advanced modeling techniques are gradually introduced throughout the HowToFit lectures. diff --git a/scripts/chapter_1_introduction/tutorial_2_fitting_data.py b/scripts/chapter_1_introduction/tutorial_2_fitting_data.py index 7ae5250..0535489 100644 --- a/scripts/chapter_1_introduction/tutorial_2_fitting_data.py +++ b/scripts/chapter_1_introduction/tutorial_2_fitting_data.py @@ -265,7 +265,7 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: We can plot the residuals with error bars based on the noise map. The plot below reveals that the model is a poor fit, as many residuals deviate significantly from zero even after accounting for the noise in each data point. -A blue line through zero is included on the plot, to make it clear where residuals are not constent with zero +A blue line through zero is included on the plot, to make it clear where residuals are not consistent with zero above the noise level. """ residual_map = data - model_data @@ -294,7 +294,9 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: The normalized residual map is computed as the residual map divided by the noise map: -\[ \text{normalized\_residual} = \frac{\text{residual\_map}}{\text{noise\_map}} = \frac{\text{data} - \text{model\_data}}{\text{noise\_map}} \] +$$ +\text{normalized\_residual} = \frac{\text{residual\_map}}{\text{noise\_map}} = \frac{\text{data} - \text{model\_data}}{\text{noise\_map}} +$$ If you're familiar with the concept of standard deviations (sigma) in statistics, the normalized residual map represents how many standard deviations the residual is from zero. For instance, a normalized residual of 2.0 (corresponding @@ -320,7 +322,9 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: The chi-squared map is calculated as: -\[ \chi^2 = \left(\frac{\text{data} - \text{model\_data}}{\text{noise\_map}}\right)^2 \] +$$ +\chi^2 = \left(\frac{\text{data} - \text{model\_data}}{\text{noise\_map}}\right)^2 +$$ The purpose of squaring the normalized residual map is to ensure all values are positive. For instance, both a normalized residual of -0.2 and 0.2 would square to 0.04, indicating the same level of fit in terms of `chi_squared`. @@ -341,7 +345,9 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: It is defined as the sum of all values in the `chi_squared_map` and is computed as: -\[ \chi^2 = \sum \left(\frac{\text{data} - \text{model\_data}}{\text{noise\_map}}\right)^2 \] +$$ +\chi^2 = \sum \left(\frac{\text{data} - \text{model\_data}}{\text{noise\_map}}\right)^2 +$$ This summing process highlights why ensuring all values in the chi-squared map are positive is crucial. If we didn't square the values (making them positive), positive and negative residuals would cancel each other out, @@ -362,9 +368,9 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: The `noise_normalization` is computed as the logarithm of the sum of squared noise values in our data: -\[ -\text{{noise\_normalization}} = \sum \log(2 \pi \text{{noise\_map}}^2) -\] +$$ +\text{noise\_normalization} = \sum \log(2 \pi \text{noise\_map}^2) +$$ This quantity is fixed because the noise-map remains constant throughout the fitting process. Despite this, including the `noise_normalization` is considered good practice due to its statistical significance. @@ -384,7 +390,9 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: This measure is calculated by taking the sum of the `chi_squared` and `noise_normalization`, and then multiplying the result by -0.5: -\[ \text{log\_likelihood} = -0.5 \times \left( \chi^2 + \text{noise\_normalization} \right) \] +$$ +\text{log\_likelihood} = -0.5 \times \left( \chi^2 + \text{noise\_normalization} \right) +$$ Why multiply by -0.5? The exact rationale behind this factor isn't critical for our current understanding. """ @@ -518,7 +526,7 @@ def plot_model_fit( The first guess correctly pinpoints that the Gaussian's peak is at 50.0, but the width and normalization are off. -The `log_likelihood` is computed and printed, however because we don't have a value to compare it to yet, its hard +The `log_likelihood` is computed and printed, however because we don't have a value to compare it to yet, it's hard to assess if it is a large or small value. """ @@ -540,7 +548,7 @@ def plot_model_fit( """ __Guess 2__ -The second guess refines the width and normalization, but the size of the Gaussian is still off. +The second guess refines the normalization, but the width of the Gaussian is still off. The `log_likelihood` is computed and printed, and increases a lot compared to the previous guess, indicating that the fit is better. @@ -643,8 +651,8 @@ def plot_model_fit( data? A residual map shows the differences between observed data and the model's predictions, often revealing patterns or areas where the model fits well or poorly. -Furthermore, can you foresee how you would calculate a log likelihood from this residual map? The log likelihood q -uantifies how well your model fits the data, incorporating both the residual values and the noise characteristics of +Furthermore, can you foresee how you would calculate a log likelihood from this residual map? The log likelihood +quantifies how well your model fits the data, incorporating both the residual values and the noise characteristics of your observations. If you find it challenging to visualize these aspects right now, that's perfectly fine. The first step is to diff --git a/scripts/chapter_1_introduction/tutorial_3_non_linear_search.py b/scripts/chapter_1_introduction/tutorial_3_non_linear_search.py index 7d79d3d..cd3c4cb 100644 --- a/scripts/chapter_1_introduction/tutorial_3_non_linear_search.py +++ b/scripts/chapter_1_introduction/tutorial_3_non_linear_search.py @@ -26,7 +26,7 @@ model instance to the data. - Fit a 1D Gaussian model to 1D data with different non-linear searches, including a maximum likelihood estimator (MLE), - Markok Chain Monte Carlo (MCMC) and nested sampling. + Markov Chain Monte Carlo (MCMC) and nested sampling. All these steps utilize **PyAutoFit**'s API for model-fitting. @@ -55,29 +55,34 @@ For example, consider a simple function: -\[ f(x) = x^2 \] +$$ +f(x) = x^2 +$$ -Here, \( x \) is the parameter input into the function \( f \), and \( f(x) \) returns \( x^2 \). This -mapping between \( x \) and \( f(x) \) defines the "parameter space" of the function, which in this case is a parabola. +Here, $x$ is the parameter input into the function $f$, and $f(x)$ returns $x^2$. This +mapping between $x$ and $f(x)$ defines the "parameter space" of the function, which in this case is a parabola. -Functions can have multiple parameters, such as \( x \), \( y \), and \( z \): +Functions can have multiple parameters, such as $x$, $y$, and $z$: -\[ f(x, y, z) = x + y^2 - z^3 \] +$$ +f(x, y, z) = x + y^2 - z^3 +$$ -Here, the mapping between \( x \), \( y \), \( z \), and \( f(x, y, z) \) defines a parameter space with three +Here, the mapping between $x$, $y$, $z$, and $f(x, y, z)$ defines a parameter space with three dimensions. This concept of a parameter space relates closely to how we define and use instances of models in model-fitting. For instance, in our previous tutorial, we used instances of a 1D Gaussian profile with -parameters \( (x, I, \sigma) \) to fit data and compute a log likelihood. +parameters $(\mathrm{centre}, N, \sigma)$ to fit data and compute a log likelihood. -This process can be thought of as complete analogous to a function \( f(x, y, z) \), where the output value is the +This process can be thought of as completely analogous to a function $f(x, y, z)$, where the output value is the log likelihood. This key function, which maps parameter values to a log likelihood, is called the "likelihood function" in statistical inference, albeit we will refer to it hereafter as the `log_likelihood_function` to be explicit that it is the log of the likelihood function. By expressing the likelihood in this manner, we can consider our model as having a parameter space -β€” a -multidimensional surface that spans all possible values of the model parameters \( x, I, \sigma \). +multidimensional surface that spans all possible values of the model parameters $\mathrm{centre}$, $N$ and $\sigma$ +(the `centre`, `normalization` and `sigma` of the `Gaussian` class). This surface is often referred to as the "likelihood surface", and our objective during model-fitting is to find its peak. @@ -132,7 +137,7 @@ __Deeper Background__ -**The descriptions of how searches work in this example are simplfied and phoenomenological and do not give a full +**The descriptions of how searches work in this example are simplified and phenomenological and do not give a full description of how they work at a deep statistical level. The goal is to provide you with an intuition for how to use them and when different searches are appropriate for different problems. Later tutorials will provide a more formal description of how these searches work.** @@ -327,10 +332,10 @@ def model_data_from(self, xvalues: np.ndarray) -> np.ndarray: parameters, fits the observed data. **Interface with Non-linear Search:** The `log_likelihood_function` is repeatedly called by the non-linear search - algorithm to assess the goodness of fit of different parameter combinations. The search algorithm call this function + algorithm to assess the goodness of fit of different parameter combinations. The search algorithm calls this function many times and maps out regions of parameter space that yield high likelihood solutions. -Below is a suitable `Analysis` class for fitting a 1D gaussian to the data loaded above. +Below is a suitable `Analysis` class for fitting a 1D Gaussian to the data loaded above. """ @@ -441,7 +446,7 @@ def log_likelihood_function(self, instance) -> float: print( """ The non-linear search has begun running. - This Jupyter notebook cell with progress once the search has completed - this could take a few minutes! + This Jupyter notebook cell will progress once the search has completed - this could take a few minutes! """ ) @@ -449,14 +454,14 @@ def log_likelihood_function(self, instance) -> float: result = search.fit(model=model, analysis=analysis) -print("The search has finished run - you may now continue the notebook.") +print("The search has finished running - you may now continue the notebook.") """ Upon completion the non-linear search returns a `Result` object, which contains information about the model-fit. The `info` attribute shows the result in a readable format. -[Above, we discussed that the `info_whitespace_length` parameter in the config files could b changed to make +[Above, we discussed that the `info_whitespace_length` parameter in the config files could be changed to make the `model.info` attribute display optimally on your computer. This attribute also controls the whitespace of the `result.info` attribute.] """ @@ -489,7 +494,7 @@ def log_likelihood_function(self, instance) -> float: capsize=2, ) plt.plot(xvalues, model_data, color="r") -plt.title("Dynesty model fit to 1D Gaussian dataset.") +plt.title("LBFGS model fit to 1D Gaussian dataset.") plt.xlabel("x values of profile") plt.ylabel("Profile normalization") plt.show() @@ -505,12 +510,18 @@ def log_likelihood_function(self, instance) -> float: To achieve a better fit with MLE, the search needs to begin in a region of parameter space where the log likelihood is higher. This process is known as "initialization," and it involves providing the search with an appropriate "starting point" in parameter space. + +The starting point is defined per parameter, so we create the model first and use its parameters as the keys of +the initializer. The values below are a deliberately imperfect guess at the true solution (`centre=50.0`, +`normalization=25.0`, `sigma=10.0`), but they are close enough for the search to climb the likelihood gradient to it. """ +model = af.Model(Gaussian) + initializer = af.InitializerParamStartPoints( { - model.centre: 55.0, - model.normalization: 20.0, - model.sigma: 8.0, + model.centre: 52.0, + model.normalization: 23.0, + model.sigma: 9.0, } ) @@ -519,15 +530,13 @@ def log_likelihood_function(self, instance) -> float: print( """ The non-linear search has begun running. - This Jupyter notebook cell with progress once the search has completed - this could take a few minutes! + This Jupyter notebook cell will progress once the search has completed - this could take a few minutes! """ ) -model = af.Model(Gaussian) - result = search.fit(model=model, analysis=analysis) -print("The search has finished run - you may now continue the notebook.") +print("The search has finished running - you may now continue the notebook.") """ By printing `result.info` and looking at the maximum log likelihood model, we can confirm the search provided a @@ -549,7 +558,7 @@ def log_likelihood_function(self, instance) -> float: capsize=2, ) plt.plot(xvalues, model_data, color="r") -plt.title("Dynesty model fit to 1D Gaussian dataset.") +plt.title("LBFGS model fit to 1D Gaussian dataset.") plt.xlabel("x values of profile") plt.ylabel("Profile normalization") plt.show() @@ -596,7 +605,7 @@ def log_likelihood_function(self, instance) -> float: print( """ The non-linear search has begun running. - This Jupyter notebook cell with progress once the search has completed - this could take a few minutes! + This Jupyter notebook cell will progress once the search has completed - this could take a few minutes! """ ) @@ -604,7 +613,7 @@ def log_likelihood_function(self, instance) -> float: result = search.fit(model=model, analysis=analysis) -print("The search has finished run - you may now continue the notebook.") +print("The search has finished running - you may now continue the notebook.") print(result.info) @@ -622,7 +631,7 @@ def log_likelihood_function(self, instance) -> float: capsize=2, ) plt.plot(xvalues, model_data, color="r") -plt.title("Dynesty model fit to 1D Gaussian dataset.") +plt.title("Emcee model fit to 1D Gaussian dataset.") plt.xlabel("x values of profile") plt.ylabel("Profile normalization") plt.show() @@ -647,6 +656,8 @@ def log_likelihood_function(self, instance) -> float: 2. We do not specify a starting point for the sigma parameter, allowing its initial values to be drawn from its priors. This illustrates that with MCMC, it’s not necessary to know a good starting point for every parameter. """ +model = af.Model(Gaussian) + initializer = af.InitializerParamBounds( { model.centre: (54.0, 56.0), @@ -663,15 +674,13 @@ def log_likelihood_function(self, instance) -> float: print( """ The non-linear search has begun running. - This Jupyter notebook cell with progress once the search has completed - this could take a few minutes! + This Jupyter notebook cell will progress once the search has completed - this could take a few minutes! """ ) -model = af.Model(Gaussian) - result = search.fit(model=model, analysis=analysis) -print("The search has finished run - you may now continue the notebook.") +print("The search has finished running - you may now continue the notebook.") print(result.info) @@ -686,7 +695,7 @@ def log_likelihood_function(self, instance) -> float: used. One often ends up having to perform "trial and error" to verify a sufficient number of steps are used. MCMC can perform badly in parameter spaces with certain types of complexity, for example when there are -are local maxima "peaks" the walkers can become stuck walking around them. +local maxima "peaks" the walkers can become stuck walking around them. __Nested Sampling__ @@ -719,7 +728,7 @@ def log_likelihood_function(self, instance) -> float: print( """ The non-linear search has begun running. - This Jupyter notebook cell with progress once the search has completed - this could take a few minutes! + This Jupyter notebook cell will progress once the search has completed - this could take a few minutes! """ ) @@ -727,7 +736,7 @@ def log_likelihood_function(self, instance) -> float: result = search.fit(model=model, analysis=analysis) -print("The search has finished run - you may now continue the notebook.") +print("The search has finished running - you may now continue the notebook.") print(result.info) @@ -758,7 +767,7 @@ def log_likelihood_function(self, instance) -> float: specify the number of steps the search should take. This method also excels in handling complex parameter spaces, particularly those with multiple peaks. This is because -the live points will identify each peak and converge around them, but then begin to be discard from a peak if higher +the live points will identify each peak and converge around them, but then begin to be discarded from a peak if higher likelihood points are found elsewhere in parameter space. In MCMC, the walkers can get stuck indefinitely around a peak, causing the method to stall. From ac0fd0df42045716897a21aed5af4b0b0b83f88a Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 14 Sep 2026 23:29:49 +0100 Subject: [PATCH 2/2] docs: regenerate the tutorial 1 markdown mirror 6f335b2 fixed the __Paths__ clone URL to point at HowToFit instead of autofit_workspace, in scripts/ and notebooks/. markdown/ was left behind: tutorial_1_models.md:104 still read PyAutoLabs/autofit_workspace, so the published mirror still sent a reader who wants HowToFit to the wrong repo. The cause is not this branch's: markdown/ is built by generate_markdown.py over config/build/markdown_examples.yaml, a different tool from the generate.py that builds notebooks/. Following the documented regeneration step rebuilds notebooks/ and silently misses markdown/. The same gap was hit twice on 2026-09-14 in HowToGalaxy and HowToLens (HowToGalaxy#75). Regenerating also brings this page up to date with script changes that were never rendered, which is most of the diff. Landed here rather than as its own PR because on main both the .py and the .md are still stale: a branch off main would duplicate this one's fix and conflict with it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_014ujQLXo85GNH7tG5eaNJ65 --- markdown/README.md | 3 + .../tutorial_1_models.md | 267 +++++++++++++++--- .../tutorial_1_models_15_0.png | Bin 0 -> 4974 bytes ...ls_19_0.png => tutorial_1_models_25_0.png} | Bin .../tutorial_1_models_33_0.png | Bin 0 -> 6030 bytes .../tutorial_1_models_39_0.png | Bin 0 -> 6030 bytes ...ls_37_0.png => tutorial_1_models_47_0.png} | Bin .../tutorial_1_models_55_0.png | Bin 0 -> 5093 bytes .../tutorial_1_models_5_0.png | Bin 0 -> 7710 bytes .../tutorial_1_models_61_1.png | Bin 0 -> 11136 bytes 10 files changed, 227 insertions(+), 43 deletions(-) create mode 100644 markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_15_0.png rename markdown/chapter_1_introduction/tutorial_1_models_files/{tutorial_1_models_19_0.png => tutorial_1_models_25_0.png} (100%) create mode 100644 markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_33_0.png create mode 100644 markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_39_0.png rename markdown/chapter_1_introduction/tutorial_1_models_files/{tutorial_1_models_37_0.png => tutorial_1_models_47_0.png} (100%) create mode 100644 markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_55_0.png create mode 100644 markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_5_0.png create mode 100644 markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_61_1.png diff --git a/markdown/README.md b/markdown/README.md index 1ff4f37..05a37ef 100644 --- a/markdown/README.md +++ b/markdown/README.md @@ -8,6 +8,9 @@ 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: Gradients](chapter_1_introduction/tutorial_6_gradients.md) β€” from `scripts/chapter_1_introduction/tutorial_6_gradients.py` +- [Tutorial 7: The Details](chapter_1_introduction/tutorial_7_the_details.md) β€” from `scripts/chapter_1_introduction/tutorial_7_the_details.py` - [Tutorial 8: Scientific Workflow](chapter_1_introduction/tutorial_8_scientific_workflow.md) β€” from `scripts/chapter_1_introduction/tutorial_8_scientific_workflow.py` +- [Tutorial Optional: Bayesian Formalism](chapter_1_introduction/tutorial_optional_bayesian_formalism.md) β€” from `scripts/chapter_1_introduction/tutorial_optional_bayesian_formalism.py` These pages are regenerated manually by PyAutoHands's `generate_markdown.py` when a curated script changes. diff --git a/markdown/chapter_1_introduction/tutorial_1_models.md b/markdown/chapter_1_introduction/tutorial_1_models.md index e828bfc..bef5723 100644 --- a/markdown/chapter_1_introduction/tutorial_1_models.md +++ b/markdown/chapter_1_introduction/tutorial_1_models.md @@ -59,7 +59,7 @@ __Contents__ This tutorial is split into the following sections: - **Paths**: Setting up the working directory path so the tutorial runs correctly on your computer. -- **Model Parameterization**: An example of how a model is parameterized and is made up of free parameters. +- **Model Parameterization**: The 1D dataset our model describes and an example of how a model is parameterized and is made up of free parameters. - **Model Composition**: Composing a model using PyAutoFit's model composition API. - **Model Creation**: Creating an instance of the model using PyAutoFit's `Model` python object. - **Model Mapping**: Mapping an input vector of parameters to the model to create an instance of the model. @@ -74,18 +74,16 @@ performed by PyAutoFit. ```python +from autofit import setup_notebook; setup_notebook() + import numpy as np import matplotlib.pyplot as plt +from os import path import autofit as af ``` - .../PyAutoNerves/autonerves/workspace.py:206: UserWarning: Cannot verify the workspace at HowToFit/scripts/chapter_1_introduction is compatible with the installed library version (2026.7.6.649): no `version.minimum_library_version` or `version.workspace_version` key in config/general.yaml and no version.txt at the workspace root. - - If you cloned the workspace from `main` rather than a release tag, set `version.workspace_version_check: False` in config/general.yaml to silence this warning. The `main` branch updates more frequently than library releases, so version mismatches are expected and not actionable for `main`-branch users. - - You can also set the environment variable PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1 to disable temporarily. - warnings.warn(_missing_version_warning(root, library_version)) + Working Directory has been set to `hf-detached` __Paths__ @@ -101,16 +99,74 @@ This setup allows PyAutoFit to: If you don't have a HowToFit clone, you can download it here: - https://github.com/PyAutoLabs/autofit_workspace + https://github.com/PyAutoLabs/HowToFit __Model Parameterization__ A model is a set of equations, numerical processes, and assumptions that describe a physical system and dataset. -In this example, our model is one or more 1-dimensional Gaussians, defined by the following equation: +In this example, our model is one or more 1-dimensional Gaussians, which describe the dataset plotted below: a +noisy 1D signal, shown in black with error bars given by its noise-map. + + +```python +dataset_path = path.join("dataset", "example_1d", "gaussian_x1") +``` + +__Dataset Auto-Simulation__ + +If the dataset does not already exist on your system, it will be created by running the corresponding +simulator script. This ensures that all example scripts can be run without manually simulating data first. + + +```python +if not path.exists(dataset_path): + import subprocess + import sys + + subprocess.run( + [sys.executable, "scripts/simulators/simulators.py"], + check=True, + ) + +data = af.util.numpy_array_from_json(file_path=path.join(dataset_path, "data.json")) +noise_map = af.util.numpy_array_from_json( + file_path=path.join(dataset_path, "noise_map.json") +) + +xvalues = np.arange(data.shape[0]) + +plt.errorbar( + xvalues, + data, + yerr=noise_map, + linestyle="", + color="k", + ecolor="k", + elinewidth=1, + capsize=2, +) +plt.title("1D Gaussian dataset.") +plt.xlabel("x values of profile") +plt.ylabel("Profile Normalization") +plt.show() +plt.clf() +``` + + + +![png](tutorial_1_models_files/tutorial_1_models_5_0.png) + + + + +
+ + +The 1D signal above was generated using a 1D Gaussian profile of the form: \begin{equation*} -g(x, I, \sigma) = \frac{N}{\sigma\sqrt{2\pi}} \exp{(-0.5 (x / \sigma)^2)} +g(x, N, \sigma) = \frac{N}{\sigma\sqrt{2\pi}} \exp{(-0.5 (x / \sigma)^2)} \end{equation*} Where: @@ -119,15 +175,16 @@ Where: - `N`: The overall normalization of the Gaussian. - -- `\sigma`: The size of the Gaussian (Full Width Half Maximum, $\mathrm{FWHM}$, is $2{\sqrt{2\ln 2}}\;\sigma$). +- $\sigma$: The size of the Gaussian (Full Width Half Maximum, $\mathrm{FWHM}$, is $2{\sqrt{2\ln 2}}\;\sigma$). While a 1D Gaussian might seem like a rudimentary model, it has many real-world applications in signal processing. For example, 1D Gaussians are fitted to datasets to measure the size of an observed signal. Thus, this model has practical real-world applications. -We now have a model, expressed as a simple 1D Gaussian. The model has three parameters, $(x, N, \sigma)$. Using -different combinations of these parameters creates different realizations of the model, which we illustrate below. +We now have a model, expressed as a simple 1D Gaussian. Note that `x` is not a free parameter: it is the coordinate +the equation is evaluated at. The three free parameters are the centre of the Gaussian, $N$ and $\sigma$, which the +`Gaussian` class written below calls `centre`, `normalization` and `sigma`. Using different combinations of these +parameters creates different realizations of the model, which we illustrate below. __Model Composition__ @@ -206,15 +263,15 @@ above `centre`, `normalization`, and `sigma`. - The default values and typing of the input arguments define whether a parameter is a single-valued float or a multi-valued tuple. For the `Gaussian` class above, no input parameters are tuples, but later examples use tuples. -- It includes functions associated with that model component, specifically the model_data function. When we create -instances of a `Gaussian` below, this function is used to generate a 1D representation of it as a NumPy array. +- It includes functions associated with that model component, specifically the `model_data_from` function. When we +create instances of a `Gaussian` below, this function is used to generate a 1D representation of it as a NumPy array. __Model Creation__ The `Gaussian` class above is a standard Python class. It does not yet act as a model component that can be used for model fitting with PyAutoFit. -To transform the Gaussian class into a model component that can be used for model fitting with PyAutoFit, we use +To transform the `Gaussian` class into a model component that can be used for model fitting with PyAutoFit, we use the `af.Model` object. This tells PyAutoFit to treat the input Python class as a model component. @@ -229,7 +286,7 @@ print(model) Gaussian (centre, UniformPrior [0], lower_limit = 0.0, upper_limit = 100.0), (normalization, LogUniformPrior [1], lower_limit = 1e-06, upper_limit = 1000000.0), (sigma, UniformPrior [2], lower_limit = 0.0, upper_limit = 25.0) -In PyAutoFit, a Model object encapsulates a model component that can be used for model fitting. It provides several +In PyAutoFit, a `Model` object encapsulates a model component that can be used for model fitting. It provides several attributes that describe the model component, such as the `total_free_parameters` attribute, which indicates the number of free parameters in the model: @@ -270,16 +327,34 @@ print(model.info) sigma UniformPrior [2], lower_limit = 0.0, upper_limit = 25.0 +The same model can also be visualized as a figure, making its structure easier to understand at a glance. + +The figure shows how the model is organized: which parameters belong to each component, and whether they are free, +fixed, shared, linked by an expression, solved during the fit, or not configured. `model.info` provides the +corresponding numerical details, including the prior assigned to each free parameter and the value of each fixed +parameter. + + +```python +af.ModelPlotter(model).figure() +``` + + + +![png](tutorial_1_models_files/tutorial_1_models_15_0.png) + + + __Model Mapping__ -In PyAutoFit, instances of model components created via the af.Model object can be instantiated by mapping an input +In PyAutoFit, instances of model components created via the `af.Model` object can be instantiated by mapping an input vector of parameters to the Python class that the model object represents. The order of parameters in the model is crucial for correctly defining the input vector. -To determine the order of parameters in the model, PyAutoFit provides the paths attribute of the model object. +To determine the order of parameters in the model, PyAutoFit provides the `paths` attribute of the model object. This attribute contains information about the parameter paths within the model. -Here's how you can access the paths attribute to understand the order of parameters in the model: +Here's how you can access the `paths` attribute to understand the order of parameters in the model: ```python @@ -289,8 +364,8 @@ print(model.paths) [('centre',), ('normalization',), ('sigma',)] -To create an instance of the Gaussian model component using PyAutoFit, following the order of parameters defined by -the paths attribute (`centre`, `normalization`, and `sigma`), you can initialize the instance as follows: +To create an instance of the `Gaussian` model component using PyAutoFit, following the order of parameters defined by +the `paths` attribute (`centre`, `normalization`, and `sigma`), you can initialize the instance as follows: ```python @@ -307,7 +382,7 @@ print(instance) Model Instance: - <__main__.Gaussian object at 0x7fe0b75dbd40> + <__main__.Gaussian object at 0x7f48b43c9340> It has the parameters of the `Gaussian` with the values input above. @@ -315,14 +390,14 @@ It has the parameters of the `Gaussian` with the values input above. ```python print("Instance Parameters \n") -print("x = ", instance.centre) +print("centre = ", instance.centre) print("normalization = ", instance.normalization) print("sigma = ", instance.sigma) ``` Instance Parameters - x = 30.0 + centre = 30.0 normalization = 2.0 sigma = 3.0 @@ -352,7 +427,7 @@ plt.clf() -![png](tutorial_1_models_files/tutorial_1_models_19_0.png) +![png](tutorial_1_models_files/tutorial_1_models_25_0.png) @@ -379,7 +454,7 @@ To demonstrate this capability, let's conclude the tutorial by composing a model component and another 1D profile, an `Exponential`, defined by the equation: \begin{equation*} -g(x, I, \lambda) = N \lambda \exp{- \lambda x } +g(x, N, \lambda) = N \lambda \exp{- \lambda x } \end{equation*} where: @@ -415,8 +490,8 @@ class Exponential: The x coordinate of the profile centre. normalization Overall normalization of the profile. - ratw - The decay rate controlling has fast the Exponential declines. + rate + The decay rate controlling how fast the Exponential declines. """ self.centre = centre self.normalization = normalization @@ -424,7 +499,7 @@ class Exponential: def model_data_from(self, xvalues: np.ndarray): """ - Returns a 1D Gaussian on an input list of Cartesian x coordinates. + Returns a 1D Exponential on an input list of Cartesian x coordinates. The input xvalues are translated to a coordinate system centred on the `Exponential`, via its `centre`. @@ -435,6 +510,11 @@ class Exponential: ---------- xvalues The x coordinates in the original reference frame of the data. + + Returns + ------- + np.array + The Exponential values at the input x coordinates. """ transformed_xvalues = np.subtract(xvalues, self.centre) return self.normalization * np.multiply( @@ -474,6 +554,21 @@ print(model.info) rate UniformPrior [8], lower_limit = 0.0, upper_limit = 1.0 +A `Collection` holds the `gaussian` and the `exponential` side by side, giving 6 free parameters across the pair. +Nothing yet joins the two components: their two `centre` parameters are separate parameters that happen to share a +name. + + +```python +af.ModelPlotter(model).figure() +``` + + + +![png](tutorial_1_models_files/tutorial_1_models_33_0.png) + + + When `Gaussian` and `Exponential` are added to a `Collection`, they are automatically assigned as `Model` objects. Therefore, there's no need to use the `af.Model` method when passing classes to a `Collection`, which makes the Python @@ -507,6 +602,24 @@ print(model.info) rate UniformPrior [14], lower_limit = 0.0, upper_limit = 1.0 +The figure is identical to the previous example, because both ways of writing the model produce the same model +structure. + +This is a useful check when composing models in different ways: if the figure looks the same, the underlying structure +of the model is the same too. Any differences between the fits must therefore come from details such as the parameter +priors or fixed values, rather than how the model is composed. + + +```python +af.ModelPlotter(model).figure() +``` + + + +![png](tutorial_1_models_files/tutorial_1_models_39_0.png) + + + A `Collection` functions analogously to a `Model`, but it includes multiple model components. This can be observed by examining its `paths` attribute, which displays paths to all 6 free parameters across both model components. @@ -537,22 +650,22 @@ The argument names input into the `Collection` define the attribute names of the ```python print("Instance Parameters \n") -print("x (Gaussian) = ", instance.gaussian.centre) +print("centre (Gaussian) = ", instance.gaussian.centre) print("normalization (Gaussian) = ", instance.gaussian.normalization) print("sigma (Gaussian) = ", instance.gaussian.sigma) -print("x (Exponential) = ", instance.exponential.centre) +print("centre (Exponential) = ", instance.exponential.centre) print("normalization (Exponential) = ", instance.exponential.normalization) -print("sigma (Exponential) = ", instance.exponential.rate) +print("rate (Exponential) = ", instance.exponential.rate) ``` Instance Parameters - x (Gaussian) = 0.1 + centre (Gaussian) = 0.1 normalization (Gaussian) = 0.2 sigma (Gaussian) = 0.3 - x (Exponential) = 0.4 + centre (Exponential) = 0.4 normalization (Exponential) = 0.5 - sigma (Exponential) = 0.01 + rate (Exponential) = 0.01 In the context of the model's equations, it is simply the sum of the equations defining the `Gaussian` @@ -582,7 +695,7 @@ plt.clf() -![png](tutorial_1_models_files/tutorial_1_models_37_0.png) +![png](tutorial_1_models_files/tutorial_1_models_47_0.png) @@ -652,6 +765,21 @@ print(model.info) sigma UniformPrior [18], lower_limit = 0.0, upper_limit = 25.0 +`centre` is one input argument of the `Gaussian2D` class, but because it is a tuple it contributes two free +parameters rather than one, so this model has 4 free parameters rather than 3. The `paths` printed below unpack the +tuple into its two entries, one per coordinate, which the input vector must supply. + + +```python +af.ModelPlotter(model).figure() +``` + + + +![png](tutorial_1_models_files/tutorial_1_models_55_0.png) + + + The `paths` attribute provides information on the order of parameters in the model, illustrating how the `centre` tuple is split into two parameters. @@ -697,6 +825,64 @@ classes to represent entirely new model components with additional parameters. These objects serve numerous other essential purposes that we will explore in subsequent tutorials. +To see this extensibility in action, the model below is composed of two `Gaussian`'s and four `Exponential`'s. Each +component has 3 free parameters, meaning this model has 18 free parameters in total, but composing it requires just +a handful of extra lines of code: + + +```python +model = af.Collection( + gaussian_0=Gaussian, + gaussian_1=Gaussian, + exponential_0=Exponential, + exponential_1=Exponential, + exponential_2=Exponential, + exponential_3=Exponential, +) + +print(model.info) + +af.ModelPlotter(model).figure() +``` + + Total Free Parameters = 18 + + model Collection (N=18) + gaussian_0 - gaussian_1 Gaussian (N=3) + exponential_0 - exponential_3 Exponential (N=3) + + gaussian_0 + centre UniformPrior [19], lower_limit = 0.0, upper_limit = 100.0 + normalization LogUniformPrior [20], lower_limit = 1e-06, upper_limit = 1000000.0 + sigma UniformPrior [21], lower_limit = 0.0, upper_limit = 25.0 + gaussian_1 + centre UniformPrior [22], lower_limit = 0.0, upper_limit = 100.0 + normalization LogUniformPrior [23], lower_limit = 1e-06, upper_limit = 1000000.0 + sigma UniformPrior [24], lower_limit = 0.0, upper_limit = 25.0 + exponential_0 + centre UniformPrior [25], lower_limit = 0.0, upper_limit = 100.0 + normalization LogUniformPrior [26], lower_limit = 1e-06, upper_limit = 1000000.0 + rate UniformPrior [27], lower_limit = 0.0, upper_limit = 1.0 + exponential_1 + centre UniformPrior [28], lower_limit = 0.0, upper_limit = 100.0 + normalization LogUniformPrior [29], lower_limit = 1e-06, upper_limit = 1000000.0 + rate UniformPrior [30], lower_limit = 0.0, upper_limit = 1.0 + exponential_2 + centre UniformPrior [31], lower_limit = 0.0, upper_limit = 100.0 + normalization LogUniformPrior [32], lower_limit = 1e-06, upper_limit = 1000000.0 + rate UniformPrior [33], lower_limit = 0.0, upper_limit = 1.0 + exponential_3 + centre UniformPrior [34], lower_limit = 0.0, upper_limit = 100.0 + normalization LogUniformPrior [35], lower_limit = 1e-06, upper_limit = 1000000.0 + rate UniformPrior [36], lower_limit = 0.0, upper_limit = 1.0 + + + + +![png](tutorial_1_models_files/tutorial_1_models_61_1.png) + + + **PyAutoFit** offers a comprehensive API for building models, which includes models constructed using NumPy arrays, hierarchies of Python classes, and graphical models where parameters are interconnected. These advanced modeling techniques are gradually introduced throughout the HowToFit lectures. @@ -729,8 +915,3 @@ task, refer to the following script: autofit_workspace/scripts/overview/new_model_component/new_model_component.py This script provides guidance on setting up the PyAutoFit configuration files associated with your custom model. - - -```python - -``` diff --git a/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_15_0.png b/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_15_0.png new file mode 100644 index 0000000000000000000000000000000000000000..b21cf848382874d7be1068ca31af9d51126a33e8 GIT binary patch literal 4974 zcmeI0X;jnKw!pEi(xON&m7LZ@oKwyKCM3Veh@pI^%Djv(H)Q zjw|Y%yqt=hjEsyt9OeMX$b5;}@t=JC<&Nf>6@0T(Ami$cag<0TRaK1w!4R8WSy$IO zJw4;-i0JI(-MN!??OKSrxs|fAIvRaJSNC{$_$?^ZjzXcSs%pi?{wx$uczgRX7)3iB z{#X7>;6Idr*eIDJBeP2;96+I^|EK(iF6`f!c5E-_w2X{`I^5wb=GL$%H#Kq`a^MX7 z$hS|?rBZ3>n%ZH7Qc*uGvbc7>c|fFo^ljA1Z#~WT{EH(MRM2PMxSGEDXz>RXiB`}1 znO$#2*_FbXp?%SFQvS>RzAbBwr~4*DjE(nM#+s+h&>M~Ov{E?5>^ydT&(B)2OgqRK z2=j{_BlC~lFLtUXYC^CdYFvDWDmF!S(n%j?VhJfQ@`*{ZZ~Xoj=|_QGK-?Mjqq&Vr zP0yP61k7N#@U(nuo~%czwbp(VHZbK93c$Vo)@6-JZ}jtI2KsHjJ+)jNI1or2@E*T$ zoeWOhJvAL;e_F$Qre^P@gGR93ww`RQeZm(m3{xj!Qc>NpjwCQEKDXhZw{j#Pn3`K& z4!qdzeGsQ?0R~&7wN{fHC|vz9g8(~1nIrr8ityzTrLA{lUT$L-MwlV_u25&_Q%?sQ zXRq905(O{=`}3MCgRypT7kkT@pa=Ng$UR~aUqLM|3K_nU;qBFh3oFl%BXTjLUtNr7 zN|Kb7lIaosziT!)#lqITKt95JZIR0h*gvuws&RR{G>yP0y9H-Q!vZ{o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C{;ZtHYJ%i|Hf7#BjX(#8Hb z^!dQJg^3e27wJ2uMm}lnH>KZ)V{7#0d^oJr4~j>bvCbnfcpEhZol@i>l=nNCdv3yRb z56mF%(sUeDz%TIY`Kkb?)IxArw`qd3E3>bLdh9V@Wp41f1WQlrT#*0HRD&Gyz zw@=}G87f6i^A;L9mt%fuI_L~>W3MxlzD6|JHchisf=kT_LtcjpB`d;xClfPTJafSA zbE7&*P2sNB1NJQy^b9zMi*<4Qd+GGHboxMq1g%3eU&B!pKj(OOq)qJB%K;UV%UWzn zrmn||4aSI4z%Dw%7mb>c+K?@1oRB}ZUNu`feGKbwH_A2lCC_Vl_hnxNG_^9F~62{MPK3G2U&p-bxa37r4 zd2Y5xf2`y^Tj)hR3}(&RnztFyC|>V^UkC~Z&~G{W`Z#oG+~>|%i;vpVqNnWCc_>ip z#!faGo2H!>MlW&z(`Y9PM=9^g)~e~N8g_#1I?QB|1vzvJ#vPg*lbVKIEfSYb{H=kb2Dj iR+{rKlOx(y8sqfJQEJu7_37X5Z^j1Z`enLzBK`*#Hp2D* literal 0 HcmV?d00001 diff --git a/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_39_0.png b/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_39_0.png new file mode 100644 index 0000000000000000000000000000000000000000..adbf8e84efd19b0102351e79224e0ffd26caa151 GIT binary patch literal 6030 zcmeHLXH=6-+C~BCqC#W=5fK%LG^x_NKxh#jL_t7NT0#+!CK3b{1q21@HI%?ZUWyUix_V!MP4*y&J%fNpq z0}m>URu~wLFg&z0w>tQz+1kPBTHE^0r}@nL_UA=D8r;@tmBmFP#hiH&7=Ejm`)X9{qJMs=br zM#Grda5ghRsv_irnvbljE4_Q#dnBHhmaQ96K~hh1W!h<5GtWyD_wZepiLI-;7QM^3 z!pgcIAK(+roGsP!3l~3|r2P?);_%^<RCbSobN=}f>Cx-fKZpO?b*0Tf56 z04m>!;^o={I7wPA)r`FU#DE!eP^0l!Eo70F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nQU4 zDOs0{D z3xbhVA0B{xCB`P*i9ZaTJ+wIWDziVVU%$%-8j;yg@}c*3`YN^Lt%!5LgDZ+2j_6@nhvAP0)!gt&D1SmUxI# zMX%Z~X0+Lh;5z69?uU0c$3{Oh`{SIQo2{B*3Q7iVB;iubbCz4fpR=wwGo-te5;+-h zU7-Ra|Bn33EY{aY$vEAFI-+oItnq&o3edw5l`pVJO$UXJZx-%~K6y%d0{yrJNs6;~T2?_Lz`IU1>84C{;ZtHYJ%i|Hf7#BjX(#8Hb z^!dQJg^3e27wJ2uMm}lnH>KZ)V{7#0d^oJr4~j>bvCbnfcpEhZol@i>l=nNCdv3yRb z56mF%(sUeDz%TIY`Kkb?)IxArw`qd3E3>bLdh9V@Wp41f1WQlrT#*0HRD&Gyz zw@=}G87f6i^A;L9mt%fuI_L~>W3MxlzD6|JHchisf=kT_LtcjpB`d;xClfPTJafSA zbE7&*P2sNB1NJQy^b9zMi*<4Qd+GGHboxMq1g%3eU&B!pKj(OOq)qJB%K;UV%UWzn zrmn||4aSI4z%Dw%7mb>c+K?@1oRB}ZUNu`feGKbwH_A2lCC_Vl_hnxNG_^9F~62{MPK3G2U&p-bxa37r4 zd2Y5xf2`y^Tj)hR3}(&RnztFyC|>V^UkC~Z&~G{W`Z#oG+~>|%i;vpVqNnWCc_>ip z#!faGo2H!>MlW&z(`Y9PM=9^g)~e~N8g_#1I?QB|1vzvJ#vPg*lbVKIEfSYb{H=kb2Dj iR+{rKlOx(y8sqfJQEJu7_37X5Z^j1Z`enLzBK`*#Hp2D* literal 0 HcmV?d00001 diff --git a/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_37_0.png b/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_47_0.png similarity index 100% rename from markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_37_0.png rename to markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_47_0.png diff --git a/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_55_0.png b/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_55_0.png new file mode 100644 index 0000000000000000000000000000000000000000..fae247c7e93d5bf3d566efbeed20bb1305cfb0ee GIT binary patch literal 5093 zcmeHKX;9PIvS-Fo1W{%j85BfBK_mz$AP9;$$QlIXpM-sp9Sn=?1c5lBqC!{#N!S@A z3H%e5k<|bJ9h4oEKtKox1B87O2wOsUc<-xM@58J6-hJP0)$I?b`<&|PKK(mg-F;r% zH8(mcEFml)AaK;gSRW7&H~`<5n+_k?U(3~h7ur7%xO)d~z~}QTD(Yrt=9tW(nwqy1 z%4-7yXiH1Gx3}N(=LuJ@YKx0Y!C*G>@=75g5jr}0czi~7Hd#_qCMxPT2M4#2k@0^73XYfZ7pA76t{tWZ`e@ ze--!jzUlJsgRV8`o%XPi!Xvx5;1uBo9K1pjfAUL``SnE6L=Ad&Nx-^ejY#RQkXw+H zd}(g}t~=t-AOB<=>}tVat#3iLtci2AD2d1PW2L`@>vg6YUKa_*&MiEPK*=(Pl@u-` z-8{Na?bva=uj(SZEvItZ`%tRT>1S^)Wd^gJUKa7vv2Ye)7gOdT#K&kuij2s}CyN|4 z!-m%No}w!*bCYqV;<2f=?gWamMfd~Ou&d)qNAYmbS2N*V6;_{Iu8^nbqgT^6ZaKZ< z-}cebrw+^xZ9N8#NvDIIh{ttU+uM6D?xq&=Jl&Y3`9~(wZzup)?^`&Xu7>0{6i-_* z`m*4m;#BPyssr}}v>31;j;CLHC}oUoKLK&BM|JwIYsA%b%uKStYAxEYW^(xzF` z5;(VD)7sGlT|a470?fWoW3OE~q7~lLULTeQ^)ITwG7NjysD#t!#y_N3F1>jipA@#| zP~*@`Pa~d^$LXp26qJg^UEWZg zV^ae$7FXZjon3P7R5Ls2S^zk@4IRrabjiq!TDm6Uhfae`8k}z|e2liBEDHhO0WxA| z#s0*A!h5Wqj{42O*F|bn#H9m;O!Z&iofec-9ND_QS z(9|R4?^$^Q^yI#Tb581cuuap^2uQT?hj{Iop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z)%cu(_5WROgEku(9~@PdFlWC~74>%XqhIxt*BisDB0w=OcjBzkpUf`%wlC@JT$TEd zuic_)5kT|RhbJT~CD-dHhP0pAk6=Yn%nIO-49xXvQ4xyL?bKjo(_-d%i3jN3AAWZ) zWI7H(O=#fIhg^r=v_Xdt6{OscUB)iCcJ9RwP3i~J_|CLHzInnU7krr2ONyFa8f$oECJ^nr+tXP#*MrvBl#E*)8A9P9 z>4PJ-bJ{*h#;ub@Sb^5bAVXT?b7-}Vpi0uaYytIu#p}OSs}Cd4J7J%})aA=pl#hei Q;eS8|dbf3pu0II-5AB$b;s5{u literal 0 HcmV?d00001 diff --git a/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_61_1.png b/markdown/chapter_1_introduction/tutorial_1_models_files/tutorial_1_models_61_1.png new file mode 100644 index 0000000000000000000000000000000000000000..c5588be61b2838922d6daf1ec16229f26770200b GIT binary patch literal 11136 zcmeHscTf{=)GmUGN>gb{2|uNY2ucY(V52vs_ufPAuoMvx6)|*3=+Z+Cp;x7aj8Oq zB1uTDk$7sTXv{_%oBLm|^PidW;fi_kUZtS>5)Bs{J!>cnG*@C(BG=(8 zQ!6_A6-t*k&mqvtxH$(hNak3A;&4NX&OQHN%WnpgNhyquyRsturpN!i$D1^M zUj1Mn#MTcY`QP);*IP%~c`t9TnH<0=nxSWIVec2=y_jo*Mju+>G`oE_@O!#K^zQo^ zeW1xu$WIVWTiZU!&_n*ig0mG&ChfD?-W64g1xdIBMA%TO8BMTh zq@>CNim)?qhlF{~Hngdt+W6|nB!4-1vYnGp(cdr@!Q9O@Yn_&bF|o&hI$O zf^Cbv`cIsu(mQTW=zd(e@^ajR<~YLthf7_L`3{8`fhPS5&XH@#Y>zWH~9 zrZQ{V`s37Z5Kg>i7KMSXByxj0GJpK#uWEwO<~JI=(Ua&L6tjrXg!p7XGCTM-uYO%$ zsoPIbQwtp8PfqX!2>+CJ@sCq3fj5I}Xd0Xs%d-Yk?0nR4Z9{LXE$a2lM7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