Skip to content

Commit 5c07d60

Browse files
reshamasOriolAbril
andauthored
Notebook: sampler_stats; update links, clean up sections (#426)
* adding myst file * remove notebook from pre-commit exception and fix * fix extra url link Co-authored-by: Oriol (ZBook) <[email protected]>
1 parent 6a5a980 commit 5c07d60

File tree

3 files changed

+35
-31
lines changed

3 files changed

+35
-31
lines changed

.pre-commit-config.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ repos:
7373
examples/case_studies/blackbox_external_likelihood.ipynb|
7474
examples/case_studies/blackbox_external_likelihood_numpy.ipynb|
7575
examples/case_studies/item_response_nba.ipynb|
76-
examples/diagnostics_and_criticism/sampler-stats.ipynb|
7776
examples/gaussian_processes/GP-MaunaLoa2.ipynb|
7877
examples/generalized_linear_models/GLM-logistic.ipynb|
7978
examples/generalized_linear_models/GLM-out-of-sample-predictions.ipynb|

examples/diagnostics_and_criticism/sampler-stats.ipynb

+22-17
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@
77
"(sampler_stats)=\n",
88
"# Sampler Statistics\n",
99
"\n",
10-
"When checking for convergence or when debugging a badly behaving\n",
11-
"sampler, it is often helpful to take a closer look at what the\n",
12-
"sampler is doing. For this purpose some samplers export\n",
13-
"statistics for each generated sample.\n",
14-
"\n",
1510
":::{post} May 31, 2022\n",
16-
":tags: diagnostics \n",
11+
":tags: diagnostics\n",
1712
":category: beginner\n",
1813
":author: Meenal Jhajharia, Christian Luhmann\n",
1914
":::"
@@ -65,6 +60,8 @@
6560
"cell_type": "markdown",
6661
"metadata": {},
6762
"source": [
63+
"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",
64+
"\n",
6865
"As a minimal example we sample from a standard normal distribution:"
6966
]
7067
},
@@ -151,7 +148,7 @@
151148
"cell_type": "markdown",
152149
"metadata": {},
153150
"source": [
154-
"- `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)."
151+
"- `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`."
155152
]
156153
},
157154
{
@@ -695,7 +692,7 @@
695692
"metadata": {},
696693
"source": [
697694
"Some points to `Note`:\n",
698-
"- 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",
695+
"- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow {ref}`ArviZ's naming convention <arviz:schema>`, while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object.\n",
699696
"- `InferenceData` also stores additional info like the date, versions used, sampling time and tuning steps as attributes."
700697
]
701698
},
@@ -1746,6 +1743,22 @@
17461743
");"
17471744
]
17481745
},
1746+
{
1747+
"cell_type": "markdown",
1748+
"metadata": {},
1749+
"source": [
1750+
"## Authors\n",
1751+
"* Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95))\n",
1752+
"* Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338))"
1753+
]
1754+
},
1755+
{
1756+
"cell_type": "markdown",
1757+
"metadata": {},
1758+
"source": [
1759+
"## Watermark"
1760+
]
1761+
},
17491762
{
17501763
"cell_type": "code",
17511764
"execution_count": 16,
@@ -1777,14 +1790,6 @@
17771790
"%watermark -n -u -v -iv -w"
17781791
]
17791792
},
1780-
{
1781-
"cell_type": "markdown",
1782-
"metadata": {},
1783-
"source": [
1784-
"* Updated by Meenal Jhajharia\n",
1785-
"* Updated by Christian Luhmann"
1786-
]
1787-
},
17881793
{
17891794
"cell_type": "markdown",
17901795
"metadata": {},
@@ -1813,7 +1818,7 @@
18131818
"name": "python",
18141819
"nbconvert_exporter": "python",
18151820
"pygments_lexer": "ipython3",
1816-
"version": "3.10.4"
1821+
"version": "3.9.10"
18171822
}
18181823
},
18191824
"nbformat": 4,

myst_nbs/diagnostics_and_criticism/sampler-stats.myst.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@ kernelspec:
1515
(sampler_stats)=
1616
# Sampler Statistics
1717

18-
When checking for convergence or when debugging a badly behaving
19-
sampler, it is often helpful to take a closer look at what the
20-
sampler is doing. For this purpose some samplers export
21-
statistics for each generated sample.
22-
2318
:::{post} May 31, 2022
24-
:tags: diagnostics
19+
:tags: diagnostics
2520
:category: beginner
2621
:author: Meenal Jhajharia, Christian Luhmann
2722
:::
@@ -43,6 +38,8 @@ az.style.use("arviz-darkgrid")
4338
plt.rcParams["figure.constrained_layout.use"] = False
4439
```
4540

41+
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.
42+
4643
As a minimal example we sample from a standard normal distribution:
4744

4845
```{code-cell} ipython3
@@ -57,7 +54,7 @@ with model:
5754
idata = pm.sample(2000, tune=1000, init=None, step=step, chains=4)
5855
```
5956

60-
- `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).
57+
- `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`.
6158

6259
```{code-cell} ipython3
6360
idata.sample_stats
@@ -94,7 +91,7 @@ The sample statistics variables are defined as follows:
9491
+++
9592

9693
Some points to `Note`:
97-
- 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.
94+
- Some of the sample statistics used by NUTS are renamed when converting to `InferenceData` to follow {ref}`ArviZ's naming convention <arviz:schema>`, while some are specific to PyMC3 and keep their internal PyMC3 name in the resulting InferenceData object.
9895
- `InferenceData` also stores additional info like the date, versions used, sampling time and tuning steps as attributes.
9996

10097
```{code-cell} ipython3
@@ -189,15 +186,18 @@ az.plot_density(
189186
);
190187
```
191188

189+
## Authors
190+
* Updated by Meenal Jhajharia in April 2021 ([pymc-examples#95](https://github.com/pymc-devs/pymc-examples/pull/95))
191+
* Updated to v4 by Christian Luhmann in May 2022 ([pymc-examples#338](https://github.com/pymc-devs/pymc-examples/pull/338))
192+
193+
+++
194+
195+
## Watermark
196+
192197
```{code-cell} ipython3
193198
%load_ext watermark
194199
%watermark -n -u -v -iv -w
195200
```
196201

197-
* Updated by Meenal Jhajharia
198-
* Updated by Christian Luhmann
199-
200-
+++
201-
202202
:::{include} ../page_footer.md
203203
:::

0 commit comments

Comments
 (0)