openghg_inversions.rhime.sampling#
RHIME sampling helpers.
- class openghg_inversions.rhime.sampling.RhimeSampler(*, draws: int = 1000, burn: int = 0, tune: int = 1000, chains: int = 4, nuts_sampler: Literal['pymc', 'nutpie', 'numpyro', 'blackjax'] | str = 'pymc', progressbar: bool = False, sample_kwargs: dict[str, Any] | None = None, sample_prior_predictive: bool | int = True, sample_posterior_predictive: bool | Sequence[str] = ('y',), posterior_predictive_kwargs: dict[str, Any] | None = None)#
Bases:
objectPyMC sampler configuration and execution for RHIME models.
- Parameters:
draws – Number of post-tuning draws requested from PyMC.
burn – Number of draws to discard from each chain after sampling.
tune – Number of PyMC tuning draws.
chains – Number of MCMC chains.
nuts_sampler – PyMC NUTS backend name.
progressbar – Whether PyMC progress output should be shown.
sample_kwargs – Extra keyword arguments forwarded to
pm.sample.sample_prior_predictive – Whether to append prior predictive draws.
sample_posterior_predictive – Whether to append posterior predictive draws, or variable names to sample.
posterior_predictive_kwargs – Extra keyword arguments forwarded to
pm.sample_posterior_predictive.
- sample(model: Model, *, variable_roles: Mapping[str, str] | None = None) InferenceData#
Sample a built RHIME model and append requested predictive groups.
- Parameters:
model – Concrete PyMC model to sample.
variable_roles – Optional semantic-role manifest from a
RhimeModelBuildResult. Posterior-predictive entries may be role names. The historical default"y"resolves to the explicitconcentrationrole when a custom model has no variable namedy.
- openghg_inversions.rhime.sampling.sample_rhime_model(model_build_result: RhimeModelBuildResult, sampler: RhimeSampler) InferenceData#
Sample a built RHIME graph at the named sampler boundary.
- Parameters:
model_build_result – Concrete graph and semantic variable roles.
sampler – Configured sampler used for posterior and predictive draws.
- Returns:
Sampled posterior and predictive groups.