openghg_inversions.models.priors#
Create reusable scalar or array-valued PyMC prior variables.
parse_prior registers continuous distributions on the active model;
lognormal_mu_sigma converts requested moments, including arrays. Optional
lognormal reparameterization exposes <name>_latent and keeps <name> as
the user-facing deterministic variable.
- openghg_inversions.models.priors.lognormal_mu_sigma(mean: float | ndarray, stdev: float | ndarray) tuple[float | ndarray, float | ndarray]#
Convert lognormal mean and stdev into PyMC’s
muandsigma.- Parameters:
mean – Requested scalar or array-valued mean of the lognormal distribution.
stdev – Requested scalar or array-valued standard deviation of the lognormal distribution.
- Returns:
A
(mu, sigma)tuple suitable forpm.Lognormal.
- openghg_inversions.models.priors.parse_prior(name: str, prior_params: dict[str, Any], **kwargs) TensorVariable#
Create a continuous PyMC prior from a prior-parameter dictionary.
- Parameters:
name – Name of the user-facing PyMC variable to create.
prior_params – Prior specification including
pdfand any distribution parameters accepted by the chosen PyMC distribution.**kwargs – Additional keyword arguments forwarded to the created PyMC variable, such as
dims.
- Returns:
The created PyMC random variable or deterministic transform.
- Raises:
ValueError – If
prior_params["pdf"]does not name a supported PyMC continuous distribution.
This helper must be called inside an active
pm.Modelcontext because it registers the created variable with the current model.