derivkit.forecasting.fisher_gaussian module#
Generalized Fisher matrix construction for parameter-dependent mean and covariance.
- derivkit.forecasting.fisher_gaussian.build_gaussian_fisher_matrix(theta0: ndarray[tuple[Any, ...], dtype[float64]], cov: ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], ndarray[tuple[Any, ...], dtype[float64]]], function: Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | ndarray[tuple[Any, ...], dtype[float64]]], *, method: str | None = None, n_workers: int = 1, rcond: float = 1e-12, symmetrize_dcov: bool = True, **dk_kwargs: Any) ndarray[tuple[Any, ...], dtype[float64]]#
Computes the Gaussian Fisher matrix.
This implements the standard Fisher matrix for a Gaussian likelihoods with parameter-dependent mean and covariance (see e.g. Eq. (2) of arXiv:1404.2854).
For Gaussian-distributed data
dwith meanmu(theta)and covarianceC(theta), the generalized Fisher matrix evaluated at theta0 is:F_ij = mu_i^T C^{-1} mu_j + 0.5 * Tr[C^{-1} C_i C^{-1} C_j].
- Parameters:
function – Callable returning the model mean
mu(theta)as a scalar (only ifn_obs == 1) or 1D array of observables with shape(n_obs,).cov –
Covariance matrix. Provide either a fixed covariance array or a callable covariance function. Supported forms are:
cov=C0: fixed covariance matrixC(theta_0)with shape(n_obs, n_obs). Heren_obsis the number of observables. In this case the covariance-derivative Fisher term will not be computed.cov=cov_fn: callablecov_fn(theta)returning the covariance matrixC(theta)evaluated at the parameter vectortheta, with shape(n_obs, n_obs).
The callable form is evaluated at
theta0to determinen_obsand (unlessC0is provided) to defineC0 = C(theta0).theta0 – Fiducial parameter vector where the Fisher matrix is evaluated.
method – Derivative method name or alias (e.g.,
"adaptive","finite"). IfNone, thederivkit.derivative_kit.DerivativeKitdefault is used.n_workers – Number of workers for per-parameter parallelisation. Default is
1(serial).rcond – Regularization cutoff for pseudoinverse fallback.
symmetrize_dcov – If
True, symmetrize each covariance derivative via0.5 * (C_i + C_i.T). Default isTrue.**dk_kwargs – Additional keyword arguments passed to
derivkit.derivative_kit.DerivativeKit.differentiate().
- Returns:
Fisher matrix with shape
(p, p)wherepis the number of parameters.- Raises:
ValueError – If
function(theta0)does not match the implied observable dimension.