ArviZ support

ArviZ support#

As of version 2.2, corner supports plotting ArviZ samples, providing a consistent interface to many MCMC samplers.

Here is a simple example of this:

import corner
import numpy as np
import arviz as az

np.random.seed(11234)

x = np.random.randn(2, 2000)
try:
    data = az.from_dict(
        posterior={"x": x, "y": np.random.randn(2, 2000, 2)},
        sample_stats={"diverging": x < -1.2},
    )
except TypeError:
    data = az.from_dict(
        {
            "posterior": {"x": x, "y": np.random.randn(2, 2000, 2)},
            "sample_stats": {"diverging": x < -1.2},
        },
    )

figure = corner.corner(data, divergences=True)
../../_images/ecd7c901571312d5a124e981bfb10dc023df656de76d7e69a75ac86c0b513b79.png

When using this interface, it is probably best to provide the truths parameter using a dictionary keyed on the variable names:

figure = corner.corner(data, truths={"x": 1.5, "y": [-0.3, 0.1]})
../../_images/6123f833f76567ef70db2a7e40afb4cacaa5b17fa6cfd2ecb6d6b3e0919fadaf.png