diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71974c5c2..e3029c2ab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -68,7 +68,6 @@ repos: examples/case_studies/blackbox_external_likelihood.ipynb| examples/case_studies/blackbox_external_likelihood_numpy.ipynb| examples/case_studies/item_response_nba.ipynb| - examples/diagnostics_and_criticism/sampler-stats.ipynb| examples/gaussian_processes/GP-MaunaLoa2.ipynb| examples/generalized_linear_models/GLM-logistic.ipynb| examples/generalized_linear_models/GLM-out-of-sample-predictions.ipynb| diff --git a/examples/diagnostics_and_criticism/sampler-stats.ipynb b/examples/diagnostics_and_criticism/sampler-stats.ipynb index 81a308d2c..2839cd9c6 100644 --- a/examples/diagnostics_and_criticism/sampler-stats.ipynb +++ b/examples/diagnostics_and_criticism/sampler-stats.ipynb @@ -7,13 +7,8 @@ "(sampler_stats)=\n", "# Sampler Statistics\n", "\n", - "When checking for convergence or when debugging a badly behaving\n", - "sampler, it is often helpful to take a closer look at what the\n", - "sampler is doing. For this purpose some samplers export\n", - "statistics for each generated sample.\n", - "\n", ":::{post} May 31, 2022\n", - ":tags: diagnostics \n", + ":tags: diagnostics\n", ":category: beginner\n", ":author: Meenal Jhajharia, Christian Luhmann\n", ":::" @@ -65,6 +60,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample.\n", + "\n", "As a minimal example we sample from a standard normal distribution:" ] }, @@ -151,7 +148,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- `Note`: NUTS provides the following statistics( these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC3, to learn more about them, [check this page](https://docs.pymc.io/api/inference.html#module-pymc3.step_methods.hmc.nuts)." + "- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, {class}`pymc.NUTS`." ] }, { @@ -695,7 +692,7 @@ "metadata": {}, "source": [ "Some points to `Note`:\n", - "- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow [ArviZ's naming convention](https://arviz-devs.github.io/arviz/schema/schema.html#sample-stats), while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object.\n", + "- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow {ref}`ArviZ's naming convention `, while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object.\n", "- `InferenceData` also stores additional info like the date, versions used, sampling time and tuning steps as attributes." ] }, @@ -1746,6 +1743,22 @@ ");" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Authors\n", + "* Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95))\n", + "* Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Watermark" + ] + }, { "cell_type": "code", "execution_count": 16, @@ -1777,14 +1790,6 @@ "%watermark -n -u -v -iv -w" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* Updated by Meenal Jhajharia\n", - "* Updated by Christian Luhmann" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -1813,7 +1818,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.9.10" } }, "nbformat": 4, diff --git a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md index ad69e24ea..8a3467ad6 100644 --- a/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md +++ b/myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md @@ -15,13 +15,8 @@ kernelspec: (sampler_stats)= # Sampler Statistics -When checking for convergence or when debugging a badly behaving -sampler, it is often helpful to take a closer look at what the -sampler is doing. For this purpose some samplers export -statistics for each generated sample. - :::{post} May 31, 2022 -:tags: diagnostics +:tags: diagnostics :category: beginner :author: Meenal Jhajharia, Christian Luhmann ::: @@ -43,6 +38,8 @@ az.style.use("arviz-darkgrid") plt.rcParams["figure.constrained_layout.use"] = False ``` +When checking for convergence or when debugging a badly behaving sampler, it is often helpful to take a closer look at what the sampler is doing. For this purpose some samplers export statistics for each generated sample. + As a minimal example we sample from a standard normal distribution: ```{code-cell} ipython3 @@ -57,7 +54,7 @@ with model: idata = pm.sample(2000, tune=1000, init=None, step=step, chains=4) ``` -- `Note`: NUTS provides the following statistics( these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC3, to learn more about them, [check this page](https://docs.pymc.io/api/inference.html#module-pymc3.step_methods.hmc.nuts). +- `Note`: NUTS provides the following statistics (these are internal statistics that the sampler uses, you don't need to do anything with them when using PyMC, to learn more about them, {class}`pymc.NUTS`. ```{code-cell} ipython3 idata.sample_stats @@ -94,7 +91,7 @@ The sample statistics variables are defined as follows: +++ Some points to `Note`: -- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow [ArviZ's naming convention](https://arviz-devs.github.io/arviz/schema/schema.html#sample-stats), while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object. +- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow {ref}`ArviZ's naming convention `, while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object. - `InferenceData` also stores additional info like the date, versions used, sampling time and tuning steps as attributes. ```{code-cell} ipython3 @@ -189,15 +186,18 @@ az.plot_density( ); ``` +## Authors +* Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95)) +* Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338)) + ++++ + +## Watermark + ```{code-cell} ipython3 %load_ext watermark %watermark -n -u -v -iv -w ``` -* Updated by Meenal Jhajharia -* Updated by Christian Luhmann - -+++ - :::{include} ../page_footer.md :::