Debian Codegraph @

docs/pages/arviz.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "markdown",
5 "metadata": {},
6 "source": [
7 "# ArviZ support\n",
8 "\n",
9 "As of version 2.2, corner supports plotting [ArviZ](https://arviz-devs.github.io/arviz/) samples, providing a consistent interface to [many MCMC samplers](https://arviz-devs.github.io/arviz/getting_started/CreatingInferenceData.html).\n",
10 "\n",
11 "Here is a simple example of this:"
12 ]
13 },
14 {
15 "cell_type": "code",
16 "execution_count": null,
17 "metadata": {
18 "tags": []
19 },
20 "outputs": [],
21 "source": [
22 "import corner\n",
23 "import numpy as np\n",
24 "import arviz as az\n",
25 "\n",
26 "np.random.seed(11234)\n",
27 "\n",
28 "x = np.random.randn(2, 2000)\n",
29 "data = az.from_dict(\n",
30 " posterior={\"x\": x, \"y\": np.random.randn(2, 2000, 2)},\n",
31 " sample_stats={\"diverging\": x < -1.2},\n",
32 ")\n",
33 "\n",
34 "figure = corner.corner(data, divergences=True)"
35 ]
36 },
37 {
38 "cell_type": "markdown",
39 "metadata": {},
40 "source": [
41 "When using this interface, it is probably best to provide the `truths` parameter using a dictionary keyed on the variable names:"
42 ]
43 },
44 {
45 "cell_type": "code",
46 "execution_count": null,
47 "metadata": {},
48 "outputs": [],
49 "source": [
50 "figure = corner.corner(data, truths={\"x\": 1.5, \"y\": [-0.3, 0.1]})"
51 ]
52 }
53 ],
54 "metadata": {
55 "kernelspec": {
56 "display_name": "Python 3",
57 "language": "python",
58 "name": "python3"
59 },
60 "language_info": {
61 "codemirror_mode": {
62 "name": "ipython",
63 "version": 3
64 },
65 "file_extension": ".py",
66 "mimetype": "text/x-python",
67 "name": "python",
68 "nbconvert_exporter": "python",
69 "pygments_lexer": "ipython3",
70 "version": "3.9.1"
71 }
72 },
73 "nbformat": 4,
74 "nbformat_minor": 4
75 }