arviz.InferenceData.__init__

InferenceData.__init__(**kwargs: Union[xarray.core.dataset.Dataset, List[xarray.core.dataset.Dataset], Tuple[xarray.core.dataset.Dataset, xarray.core.dataset.Dataset]]) None[source]

Initialize InferenceData object from keyword xarray datasets.

Parameters
kwargs :

Keyword arguments of xarray datasets

Examples

Initiate an InferenceData object from scratch, not recommended. InferenceData objects should be initialized using from_xyz methods, see Data for more details.

In [1]: import arviz as az
   ...: import numpy as np
   ...: import xarray as xr
   ...: dataset = xr.Dataset(
   ...:     {
   ...:         "a": (["chain", "draw", "a_dim"], np.random.normal(size=(4, 100, 3))),
   ...:         "b": (["chain", "draw"], np.random.normal(size=(4, 100))),
   ...:     },
   ...:     coords={
   ...:         "chain": (["chain"], np.arange(4)),
   ...:         "draw": (["draw"], np.arange(100)),
   ...:         "a_dim": (["a_dim"], ["x", "y", "z"]),
   ...:     }
   ...: )
   ...: idata = az.InferenceData(posterior=dataset, prior=dataset)
   ...: idata
   ...: 
Out[1]: 
Inference data with groups:
	> posterior
	> prior

We have created an InferenceData object with two groups. Now we can check its contents:

In [2]: idata.posterior
Out[2]: 
<xarray.Dataset>
Dimensions:  (chain: 4, draw: 100, a_dim: 3)
Coordinates:
  * chain    (chain) int64 0 1 2 3
  * draw     (draw) int64 0 1 2 3 4 5 6 7 8 9 ... 90 91 92 93 94 95 96 97 98 99
  * a_dim    (a_dim) <U1 'x' 'y' 'z'
Data variables:
    a        (chain, draw, a_dim) float64 -0.3491 -1.644 -0.3833 ... 0.37 0.0739
    b        (chain, draw) float64 1.713 -0.594 2.109 ... -1.325 -1.771 -0.5592