Linearization
- class pmrf.stats.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:
ModuleThe linearisation of one fit at a model.
Built by
pmrf.objectives.evaluators.MarginalLogLikelihood.linearize(). Columns ofJ_h, and rows and columns ofF_h, follow the model parameters intheta_namesorder, each flattened in C order to its size intheta_shapes. Rows and columns ofF_psifollow the hyperparameters inpsi_namesorder 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_shapes: tuple[tuple[int, ...], ...]
The shape of each hyperparameter’s value, in
psi_namesorder.
- 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_handF_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_namesorder.