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 d with mean mu(theta) and covariance C(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 if n_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 matrix C(theta_0) with shape (n_obs, n_obs). Here n_obs is the number of observables. In this case the covariance-derivative Fisher term will not be computed.

    • cov=cov_fn: callable cov_fn(theta) returning the covariance matrix C(theta) evaluated at the parameter vector theta, with shape (n_obs, n_obs).

    The callable form is evaluated at theta0 to determine n_obs and (unless C0 is provided) to define C0 = C(theta0).

  • theta0 – Fiducial parameter vector where the Fisher matrix is evaluated.

  • method – Derivative method name or alias (e.g., "adaptive", "finite"). If None, the derivkit.derivative_kit.DerivativeKit default 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 via 0.5 * (C_i + C_i.T). Default is True.

  • **dk_kwargs – Additional keyword arguments passed to derivkit.derivative_kit.DerivativeKit.differentiate().

Returns:

Fisher matrix with shape (p, p) where p is the number of parameters.

Raises:

ValueError – If function(theta0) does not match the implied observable dimension.