Skip to content

Commit 0ebf838

Browse files
committed
better docs
1 parent 11e653b commit 0ebf838

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

docsrc/examples/MCMC Sampling.ipynb

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@
316316
},
317317
"outputs": [],
318318
"source": [
319-
"fit.summary()"
319+
"eight_schools_fit.summary()"
320320
]
321321
},
322322
{
@@ -344,6 +344,15 @@
344344
"## Accessing the sampler outputs"
345345
]
346346
},
347+
{
348+
"cell_type": "code",
349+
"execution_count": null,
350+
"metadata": {},
351+
"outputs": [],
352+
"source": [
353+
"fit = model.sample(data='bernoulli.data.json')"
354+
]
355+
},
347356
{
348357
"cell_type": "markdown",
349358
"metadata": {},
@@ -375,7 +384,10 @@
375384
"cell_type": "markdown",
376385
"metadata": {},
377386
"source": [
378-
"### Extracting the draws as structured Stan program variables"
387+
"### Extracting the draws as structured Stan program variables\n",
388+
"\n",
389+
"Per-variable draws can be accessed as either a numpy.ndarray object\n",
390+
"via method `stan_variable` or as an xarray.Dataset object via `draws_xr`."
379391
]
380392
},
381393
{
@@ -384,8 +396,7 @@
384396
"metadata": {},
385397
"outputs": [],
386398
"source": [
387-
"for k, v in fit.stan_variables().items():\n",
388-
" print(f'name: {k}, shape: {v.shape}')"
399+
"fit.stan_variable('theta')"
389400
]
390401
},
391402
{
@@ -401,7 +412,7 @@
401412
"cell_type": "markdown",
402413
"metadata": {},
403414
"source": [
404-
"### Extracting sampler method diagnostics"
415+
"The `stan_variables` method returns a Python `dict` over all Stan variables in the output."
405416
]
406417
},
407418
{
@@ -410,17 +421,25 @@
410421
"metadata": {},
411422
"outputs": [],
412423
"source": [
413-
"for k, v in fit.method_variables().items():\n",
424+
"for k, v in fit.stan_variables().items():\n",
414425
" print(f'name: {k}, shape: {v.shape}')"
415426
]
416427
},
428+
{
429+
"cell_type": "markdown",
430+
"metadata": {},
431+
"source": [
432+
"### Extracting sampler method diagnostics"
433+
]
434+
},
417435
{
418436
"cell_type": "code",
419437
"execution_count": null,
420438
"metadata": {},
421439
"outputs": [],
422440
"source": [
423-
"print(f'divergences per chain?\\n{fit.divergences}\\niterations at maxtreedepth per chain?\\n{fit.max_treedepths}')"
441+
"for k, v in fit.method_variables().items():\n",
442+
" print(f'name: {k}, shape: {v.shape}')"
424443
]
425444
},
426445
{

0 commit comments

Comments
 (0)