log_prior

pmrf.parameters.log_prior(tree, *, space: Literal['raw', 'declared', 'physical'] = 'declared') → Array

Returns the log prior density of a model’s parameters, in one space.

For declared values \(x\) with priors \(p(x)\), scales \(s\), and raw values \(z\) mapped to declared space by \(x = f(z)\):

\[\log p_{\text{declared}} = \sum_i \log p_i(x_i)\]

$$log p_{text{physical}} = log p_{text{declared}} - sum_i n_i log |s_i|$$

\[\log p_{\text{raw}} = \log p_{\text{declared}} + \sum_i \log \left|\det \frac{\partial f_i}{\partial z_i}\right| + \sum_j \log \left|\det \frac{\partial x_j}{\partial z_j}\right|\]

where \(n_i\) is the number of elements in parameter \(i\) and \(j\) runs over joint priors. The extra terms are the change-of-variables formula [1].

Parameters without a prior have a flat prior and add no prior or scale term. The first Jacobian sum covers free, constrained parameters only. Fixed and frozen parameters add their prior as a constant.

Parameters under a joint prior (see prior()) are scored by it instead of by their own priors, and a value outside a parameter’s bounds scores \(-\infty\). In raw space they are represented by the prior’s whitened vector \(z_j\), so the second Jacobian sum replaces the first for them.

Joint contributions are summed over all leading batch axes, giving a scalar total alongside independent priors.

Parameters:
  • tree (PyTree) – A model, or any collection of models and parameters. Must still be wrapped.

  • space ({'declared', 'physical', 'raw'}, default='declared') – The space the density is over.

Returns:

A scalar.

Return type:

jax.Array

References