posterior_covariance_factor
- pmrf.stats.linearization.posterior_covariance_factor(linearizations: Sequence[Linearization], model: PyTree, space: Literal['raw', 'declared', 'physical'] = 'declared', prior_precision: Literal['moment_matched', 'hessian'] = 'moment_matched') Array
A square root of the linearised posterior covariance of free parameters.
Mathematical Formulation
Stack the whitened Jacobians of independent fits with a square root of the prior precision, then use the singular values of that stack:
\[\begin{split}A = \begin{bmatrix}L_1^{-1}J_{h,1} \\ \cdots \\ L_k^{-1}J_{h,k} \\ \Sigma_0^{-1/2}\end{bmatrix}, \qquad A = U S V^\top, \qquad W = V S^{-1}, \qquad \Sigma_\text{post} = W W^\top.\end{split}\]With
prior_precision='moment_matched', each prior is replaced by the Gaussian of the same mean and variance, so a parameter with its own prior adds\[\Sigma_{0,ii}^{-1} = 1 / \operatorname{Var}[\theta_i]\]from the distribution’s
variance(), in space: a declared-space variance times the squared scale in physical space. A joint multivariate normal prior adds its precision block. This keeps a uniform or log-uniform prior from adding no information, which would leave a weakly constrained parameter’s posterior far wider than its prior’s support. It applies to the linearisation only; the MAP objective keeps the true prior.With
prior_precision='hessian', \(\Sigma_0^{-1} = -\nabla^2\log p(\theta)\) in space at the linearisation point. This local approximation is only meaningful where the prior is log-concave, and a uniform prior inside its bounds adds zero.Either way, a symmetric eigendecomposition of \(\Sigma_0^{-1}\) supplies its square root, with negative eigenvalues clipped to zero, and a parameter without a prior adds zero prior precision.
- Parameters:
linearizations (Sequence[Linearization]) – One linearisation per independent fit, each of model in space.
model (PyTree) – The model the linearisations were taken at, carrying the prior. Must still be wrapped.
space ({'declared', 'physical', 'raw'}, default='declared') – The space of the parameter values. See
pmrf.Param.prior_precision ({'moment_matched', 'hessian'}, default='moment_matched') – How the prior’s precision is taken, as above.
- Returns:
A factor
Wwith shape(p, p)such thatW @ W.Tis the covariance over model parameters intheta_namesorder.- Return type:
jax.Array
- Raises:
ValueError – If no linearisation is given, one is over other parameters or another space, or prior_precision is unknown.
NotImplementedError – With
prior_precision='moment_matched', if space is'raw', a prior is over raw space, a prior has novariance(), or a joint prior is not a multivariate normal.