Skip to content

Commit d6d5bd3

Browse files
committed
Clarify docs on using sampler output as inits
1 parent b18d450 commit d6d5bd3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

docsrc/users-guide/examples/VI as Sampler Inits.ipynb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"## Using Estimates from Variational, Laplace, or Optimization Methods to Initialize the NUTS-HMC Sampler\n",
7+
"## Initializing the NUTS-HMC sampler\n",
88
"\n",
9-
"In this example, we show how to use parameter estimates returned by Stan's various posterior approximation or optimization algorithms as initial values for Stan's NUTS-HMC sampler. These include:\n",
9+
"In this example, we show how to use parameter estimates returned by any of Stan's inference algorithms as initial values for Stan's NUTS-HMC sampler. These include:\n",
1010
"\n",
1111
"* [Pathfinder ](https://mc-stan.org/docs/cmdstan-guide/pathfinder-config.html) \n",
1212
"* [ADVI ](https://mc-stan.org/docs/cmdstan-guide/variational_config.html) \n",
1313
"* [Laplace](https://mc-stan.org/docs/cmdstan-guide/laplace_sample_config.html)\n",
1414
"* [Optimization](https://mc-stan.org/docs/cmdstan-guide/optimize_config.html)\n",
15+
"* [NUTS-HMC MCMC](https://mc-stan.org/docs/cmdstan-guide/mcmc_config.html)\n",
1516
"\n",
16-
"By default, the NUTS-HMC sampler randomly initializes all model parameters uniformly in the interval $(-2, 2)$. If this interval is far from the typical set of the posterior, initializing sampling from these approximation algorithms can speed up and improve adaptation.\n",
17+
"By default, the NUTS-HMC sampler randomly initializes all (unconstrained) model parameters uniformly in the interval (-2, 2). If this interval is far from the typical set of the posterior, initializing sampling from these approximation algorithms can speed up and improve adaptation.\n",
1718
"\n",
1819
"### Model and data\n",
1920
"\n",
@@ -49,7 +50,7 @@
4950
"source": [
5051
"### Demonstration with Stan's `pathfinder` method\n",
5152
"\n",
52-
"The approximation methods all follow the same general pattern of usage. First, we call the \n",
53+
"Initializing the sampler with estimates from any previous inference algorithm follows the same general usage pattern. First, we call the \n",
5354
"corresponding method on the `CmdStanModel` object. From the resulting fit, we call the `.create_inits()` \n",
5455
"method to construct a set of per-chain initializations for the model parameters. To make it explicit, \n",
5556
"we will walk through the process using the `pathfinder` method (which wraps the \n",
@@ -84,7 +85,7 @@
8485
"source": [
8586
"Posteriordb provides reference posteriors for all models. For the blr model, conditioned on the dataset `sblri.json`, the reference posteriors can be found in the [sblri-blr.json](https://github.com/stan-dev/posteriordb/blob/master/posterior_database/reference_posteriors/summary_statistics/mean/mean/sblri-blr.json) file.\n",
8687
"\n",
87-
"The reference posteriors for all elements of `beta` and `sigma` are all very close to $1.0$.\n",
88+
"The reference posteriors for all elements of `beta` and `sigma` are all very close to 1.0.\n",
8889
"\n",
8990
"The experiments reported in Figure 3 of the paper [Pathfinder: Parallel quasi-Newton variational inference](https://arxiv.org/abs/2108.03782) by Zhang et al. show that Pathfinder provides a better estimate of the posterior, as measured by the 1-Wasserstein distance to the reference posterior, than 75 iterations of the warmup Phase I algorithm used by the NUTS-HMC sampler.\n",
9091
"Furthermore, Pathfinder is more computationally efficient, requiring fewer evaluations of the log density and gradient functions. Therefore, using the Pathfinder estimates to initialize the parameter values for the NUTS-HMC sampler can allow the sampler to do a better job of adapting the stepsize and metric during warmup, resulting in better performance and estimation.\n",
@@ -191,7 +192,7 @@
191192
"cell_type": "markdown",
192193
"metadata": {},
193194
"source": [
194-
"### Other approximation algorithms"
195+
"### Other inference algorithms"
195196
]
196197
},
197198
{
@@ -349,7 +350,7 @@
349350
"cell_type": "markdown",
350351
"metadata": {},
351352
"source": [
352-
"It is also possible to use the output of the `sample()` method to construct inits to be fed into a future sampling run:"
353+
"It is also possible to use the output of the `sample()` method itself to construct inits to be fed into a future sampling run:"
353354
]
354355
},
355356
{

0 commit comments

Comments
 (0)