derivkit.forecast_kit module

Provides the ForecastKit class.

A light wrapper around LikelihoodExpansion that exposes a simple API for Fisher and DALI tensors.

Typical usage example:

>>> fk = ForecastKit(function=model, theta0=theta0, cov=cov)
>>> fisher_matrix = fk.fisher(method="adaptive", n_workers=2)
>>> dali_g, dali_h = fk.dali(method="adaptive", n_workers=4)
>>> dn = fk.delta_nu(data_with=data_with_systematics, data_without=data_without_systematics)
>>> bias, dtheta = fk.fisher_bias(fisher_matrix=fisher_matrix, delta_nu=dn, method="finite")
class derivkit.forecast_kit.ForecastKit(function: Callable[[Sequence[float] | ndarray], ndarray], theta0: Sequence[float] | ndarray, cov: ndarray)

Bases: object

Provides access to Fisher and DALI likelihood-expansion tensors.

Initialises the forecaster with model, fiducials, and covariance.

Parameters:
  • function – Model mapping parameters to observables (1D array-like in, 1D array out).

  • theta0 – Fiducial parameter values (shape (P,)). Here, P is the number of model parameters (P = len(theta0))

  • cov – Observables covariance (shape (N, N)). N is the number of observables (N = cov.shape[0])

dali(*, method: str | None = None, n_workers: int = 1, dk_kwargs: dict | None = None) tuple[ndarray, ndarray]

Return the doublet-DALI tensors (G, H).

Shapes are (P,P,P) and (P,P,P,P), where P is the number of model parameters.

delta_nu(data_with: ndarray, data_without: ndarray)

Return the delta_nu vector with shape (N,) with N being the number of observables.

fisher(*, method: str | None = None, n_workers: int = 1, dk_kwargs: dict | None = None) ndarray

Return the Fisher information matrix with shape (P, P) with P being the number of model parameters.

fisher_bias(*, fisher_matrix: ndarray, delta_nu: ndarray, method: str | None = None, n_workers: int = 1, dk_kwargs: dict | None = None, rcond: float = 1e-12) tuple[ndarray, ndarray]

Return the Fisher bias vector with shape (P,) with P being the number of model parameters.