pymc.compute_deterministics#
- pymc.compute_deterministics(dataset, *, var_names=None, model=None, sample_dims=('chain', 'draw'), merge_dataset=False, progressbar=True, compile_kwargs=None)[source]#
Compute model deterministics given a dataset with values for model variables.
- Parameters:
- dataset
Dataset
Dataset with values for model variables. Commonly InferenceData[“posterior”].
- var_namessequence of
str
, optional List of names of deterministic variable to compute. If None, compute all deterministics in the model.
- model
Model
, optional Model to use. If None, use context model.
- sample_dimssequence of
str
, default (“chain”, “draw”) Sample (batch) dimensions of the dataset over which to compute the deterministics.
- merge_datasetbool, default
False
Whether to extend the original dataset or return a new one.
- progressbarbool, default
True
Whether to display a progress bar in the command line.
- progressbar_theme
Theme
, optional Custom theme for the progress bar.
- compile_kwargs: dict, optional
Additional arguments passed to model.compile_fn.
- dataset
- Returns:
Dataset
Dataset with values for the deterministics.
Examples
import pymc as pm with pm.Model(coords={"group": (0, 2, 4)}) as m: mu_raw = pm.Normal("mu_raw", 0, 1, dims="group") mu = pm.Deterministic("mu", mu_raw.cumsum(), dims="group") trace = pm.sample(var_names=["mu_raw"], chains=2, tune=5 draws=5) assert "mu" not in trace.posterior with m: trace.posterior = pm.compute_deterministics(trace.posterior, merge_dataset=True) assert "mu" in trace.posterior