marginalize#

pymc_extras.marginalize(model: Model, rvs_to_marginalize: TensorVariable | Sequence[TensorVariable] | str | Sequence[str]) MarginalModel[source]#

Marginalize a subset of variables in a PyMC model.

This creates a class of MarginalModel from an existing Model, with the specified variables marginalized.

See documentation for MarginalModel for more information.

Parameters:
  • model (Model) – PyMC model to marginalize. Original variables well be cloned.

  • rvs_to_marginalize (Sequence[TensorVariable]) – Variables to marginalize in the returned model.

Returns:

marginal_model – Marginal model with the specified variables marginalized.

Return type:

MarginalModel