|
316 | 316 | }, |
317 | 317 | "outputs": [], |
318 | 318 | "source": [ |
319 | | - "fit.summary()" |
| 319 | + "eight_schools_fit.summary()" |
320 | 320 | ] |
321 | 321 | }, |
322 | 322 | { |
|
344 | 344 | "## Accessing the sampler outputs" |
345 | 345 | ] |
346 | 346 | }, |
| 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 | + }, |
347 | 356 | { |
348 | 357 | "cell_type": "markdown", |
349 | 358 | "metadata": {}, |
|
375 | 384 | "cell_type": "markdown", |
376 | 385 | "metadata": {}, |
377 | 386 | "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`." |
379 | 391 | ] |
380 | 392 | }, |
381 | 393 | { |
|
384 | 396 | "metadata": {}, |
385 | 397 | "outputs": [], |
386 | 398 | "source": [ |
387 | | - "for k, v in fit.stan_variables().items():\n", |
388 | | - " print(f'name: {k}, shape: {v.shape}')" |
| 399 | + "fit.stan_variable('theta')" |
389 | 400 | ] |
390 | 401 | }, |
391 | 402 | { |
|
401 | 412 | "cell_type": "markdown", |
402 | 413 | "metadata": {}, |
403 | 414 | "source": [ |
404 | | - "### Extracting sampler method diagnostics" |
| 415 | + "The `stan_variables` method returns a Python `dict` over all Stan variables in the output." |
405 | 416 | ] |
406 | 417 | }, |
407 | 418 | { |
|
410 | 421 | "metadata": {}, |
411 | 422 | "outputs": [], |
412 | 423 | "source": [ |
413 | | - "for k, v in fit.method_variables().items():\n", |
| 424 | + "for k, v in fit.stan_variables().items():\n", |
414 | 425 | " print(f'name: {k}, shape: {v.shape}')" |
415 | 426 | ] |
416 | 427 | }, |
| 428 | + { |
| 429 | + "cell_type": "markdown", |
| 430 | + "metadata": {}, |
| 431 | + "source": [ |
| 432 | + "### Extracting sampler method diagnostics" |
| 433 | + ] |
| 434 | + }, |
417 | 435 | { |
418 | 436 | "cell_type": "code", |
419 | 437 | "execution_count": null, |
420 | 438 | "metadata": {}, |
421 | 439 | "outputs": [], |
422 | 440 | "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}')" |
424 | 443 | ] |
425 | 444 | }, |
426 | 445 | { |
|
0 commit comments