Linearization

class pmrf.stats.linearization.Linearization(J_h: Array, residual: Array, chol: Array, F_h: Array, F_psi: Array, theta_names: tuple[str, ...], theta_shapes: tuple[tuple[int, ...], ...], psi_names: tuple[str, ...], psi_shapes: tuple[tuple[int, ...], ...], space: Space)

Bases: Module

The linearisation of one fit at a model.

Built by pmrf.objectives.evaluators.MarginalLogLikelihood.linearize(). Columns of J_h, and rows and columns of F_h, follow the model parameters in theta_names order, each flattened in C order to its size in theta_shapes. Rows and columns of F_psi follow the hyperparameters in psi_names order in the same way.

unflatten_psi(vector: Array) → dict[str, Array]

Map a flat vector over the hyperparameters, such as a row of F_psi, back to names.

unflatten_theta(vector: Array) → dict[str, Array]

Map a flat vector over the model parameters, such as a row of F_h, back to names.

F_h: Array

The model-parameter Fisher matrix \(F_h = \sum_b J_{h,b}^\top \Sigma_{d,b}^{-1} J_{h,b}\), with shape (p, p).

F_psi: Array

The hyperparameter Fisher matrix $[F_\psi]_{ij} = \tfrac{1}{2} \sum_b \operatorname{tr}\big(\Sigma_{d,b}^{-1} J_{\Sigma,i}\, \Sigma_{d,b}^{-1} J_{\Sigma,j}\big)\(, with \)J_{\Sigma,i} = \partial \Sigma_{d,b} / \partial \psi_i$ and shape (q, q). With no free hyperparameters it has shape (0, 0).

J_h: Array

The observation Jacobian \(J_h = \partial h / \partial \theta = -\partial r / \partial \theta\) in event space, with shape (*batch, N, p).

chol: Array

The lower Cholesky factor of the data covariance \(\Sigma_d = K + \Sigma_n\), at its own batch shape, which broadcasts to batch.

psi_names: tuple[str, ...]

The names of the hyperparameters, in F_psi order.

psi_shapes: tuple[tuple[int, ...], ...]

The shape of each hyperparameter’s value, in psi_names order.

residual: Array

The residual \(r\) in event space, with shape (*batch, N).

space: Literal['raw', 'declared', 'physical']

The space the parameter values, and so J_h, F_h and F_psi, are in.

theta_names: tuple[str, ...]

The names of the model parameters, in column order.

theta_shapes: tuple[tuple[int, ...], ...]

The shape of each model parameter’s value, in theta_names order.