arviz.concat#
- arviz.concat(*args, dim: Optional[str] = 'None', copy: bool = 'True', inplace: Literal[True], reset_dim: bool = 'True') None[source]#
- arviz.concat(*args, dim: Optional[str] = 'None', copy: bool = 'True', inplace: Literal[False], reset_dim: bool = 'True') arviz.data.inference_data.InferenceData
- arviz.concat(ids: Iterable[arviz.data.inference_data.InferenceData], dim: Optional[str] = None, *, copy: bool = 'True', inplace: Literal[False], reset_dim: bool = 'True') arviz.data.inference_data.InferenceData
- arviz.concat(ids: Iterable[arviz.data.inference_data.InferenceData], dim: Optional[str] = None, *, copy: bool = 'True', inplace: Literal[True], reset_dim: bool = 'True') None
- arviz.concat(ids: Iterable[arviz.data.inference_data.InferenceData], dim: Optional[str] = None, *, copy: bool = 'True', inplace: bool = 'False', reset_dim: bool = 'True') Optional[arviz.data.inference_data.InferenceData]
Concatenate InferenceData objects.
Concatenates over group, chain or draw. By default concatenates over unique groups. To concatenate over chain or draw function needs identical groups and variables.
The variables in the data -group are merged if dim are not found.
- Parameters
- *argsInferenceData
Variable length InferenceData list or Sequence of InferenceData.
- dimstr, optional
If defined, concatenated over the defined dimension. Dimension which is concatenated. If None, concatenates over unique groups.
- copybool
If True, groups are copied to the new InferenceData object. Used only if dim is None.
- inplacebool
If True, merge args to first object.
- reset_dimbool
Valid only if dim is not None.
- Returns
- InferenceData
A new InferenceData object by default. When inplace==True merge args to first arg and return None
See also
add_groupsAdd new groups to InferenceData object.
extendExtend InferenceData with groups from another InferenceData.
Examples
Use
concatmethod to concatenate InferenceData objects. This will concatenates over unique groups by default. We first create anInferenceDataobject:In [1]: import arviz as az ...: import numpy as np ...: data = { ...: "a": np.random.normal(size=(4, 100, 3)), ...: "b": np.random.normal(size=(4, 100)), ...: } ...: coords = {"a_dim": ["x", "y", "z"]} ...: dataA = az.from_dict(data, coords=coords, dims={"a": ["a_dim"]}) ...: dataA ...: Out[1]: Inference data with groups: > posterior
We have created an
InferenceDataobject with default group ‘posterior’. Now, we will create anotherInferenceDataobject:In [2]: dataB = az.from_dict(prior=data, coords=coords, dims={"a": ["a_dim"]}) ...: dataB ...: Out[2]: Inference data with groups: > prior
We have created another
InferenceDataobject with group ‘prior’. Now, we will concatenate these twoInferenceDataobjects:In [3]: az.concat(dataA, dataB) Out[3]: Inference data with groups: > posterior > prior
Now, we will concatenate over chain (or draw). It requires identical groups and variables. Here we are concatenating two identical
InferenceDataobjects over dimension chain:In [4]: az.concat(dataA, dataA, dim="chain") Out[4]: Inference data with groups: > posterior
It will create an
InferenceDatawith the original group ‘posterior’. In similar way, we can also concatenate over draws.