pespace.inference.fisher¶
Fisher matrix computation for the Whittle likelihood.
In the high-SNR regime the likelihood can be expanded as a series in
1 / rho; keeping the leading order, the posterior distribution with
uniform priors is approximated by a multivariate Gaussian distribution with
means given by the fiducial parameters and covariance matrix given by the
inverse of the Fisher information matrix (Vallisneri 2008),
where the noise-weighted inner product is
Functions
|
Compute the Fisher information matrix at one or more fiducial parameter sets. |
|
Draw random samples from the Gaussian approximation |
|
Wrap the angle parameters of a sample set into finite canonical ranges. |
- pespace.inference.fisher.fisher_matrix(likelihood, fiducial_params, batch_size=None)[source]¶
Compute the Fisher information matrix at one or more fiducial parameter sets.
The derivatives of the model response with respect to all parameters of the likelihood are computed with forward-mode automatic differentiation, and the Fisher matrix is assembled from the noise-weighted inner products of the derivatives, summed over all detectors and requested channels,
F_ij = 4 * df * Re sum_{c, f} conj(ds_i(f)) * ds_j(f) / psd_c(f).A single parameter set returns a single matrix; a batch of parameter sets is evaluated with
vmap(optionally split into chunks bybatch_size), returning one matrix per set.- Parameters:
likelihood (WhittleLikelihoodJax) – Likelihood instance defining the waveform model, the detectors with their noise power spectral densities, and the requested TDI channels. The observed data of the detectors is not used: the Fisher matrix only depends on the model and the noise power spectral densities.
fiducial_params (dict) – Fiducial parameters at which the Fisher matrix is evaluated, e.g. the injected parameters of the simulated signal. Must contain all parameters of
likelihood.likelihood_param_type(the waveform parameters followed by the response parameters); additional entries are ignored. A single parameter set is given by scalar values; a batch of parameter sets is given by 1-D arrays whose (common) leading axis enumerates the sets, with scalar entries broadcast over the batch.batch_size (int or None, optional) – Number of parameter sets evaluated at once within
vmap.None(default) evaluates the whole batch with a singlevmapcall; an integer evaluates the batch in chunks of that size, bounding the memory footprint of large batches. Ignored for a single parameter set.
- Returns:
Fisher matrix of shape
(N_params, N_params)for a single parameter set, or(N_batch, N_params, N_params)for a batch ofN_batchparameter sets.N_paramsis the number of parameters oflikelihood.likelihood_param_type, and the rows and columns follow the order of its fields.- Return type:
jnp.ndarray
Notes
The posterior distribution is approximated by a multivariate Gaussian with mean
fiducial_paramsand covariance matrixjnp.linalg.inv(fisher_matrix(...)).When the observed data are noiseless and equal to the response of
fiducial_params, the Fisher matrix equals minus the Hessian oflog_likelihood()evaluated atfiducial_params.
- pespace.inference.fisher.sample_from_fisher(fisher, num, rkey_seed=0)[source]¶
Draw random samples from the Gaussian approximation
N(0, F^{-1}).The high-SNR posterior approximation associated with a Fisher matrix
Fis a multivariate Gaussian whose mean is given by the fiducial parameters and whose covariance matrix isF^{-1}(seefisher_matrix()). This function draws zero-mean samples from that Gaussian; the fiducial parameter values must be added by the caller.The samples are obtained without forming or inverting the covariance matrix. The Fisher matrix is first rescaled to unit diagonal with the dimensionless matrix
F' = F / (sqrt(diag(F)) outer sqrt(diag(F))), which removes the disparity of the parameter units (for a representative mixed-unit gravitational-wave case the condition number drops from ~1e19 to ~1e8, leaving a comfortable margin within float64). The scaled matrix is factorized with a Cholesky decomposition,F' = L L^T, and each sample is computed by solving the triangular systemL^T x' = zfor standard normalz, so thatCov(x') = L^{-T} L^{-1} = F'^{-1}; the samples are then rescaled back to the original units. The solve is backward stable and avoids both the explicit matrix inversion and the loss of symmetry and positive definiteness that make a naiveinv(F)-then-sample route unreliable at such condition numbers.- Parameters:
fisher (array_like, shape (N, N)) – Fisher information matrix, symmetric positive definite, with rows and columns ordered as the parameters of the likelihood.
num (int) – Number of samples to draw.
rkey_seed (int, optional) – Seed used to draw the standard normal variates. Defaults to 0, so repeated calls return identical samples.
- Returns:
Zero-mean samples with covariance matrix
fisher^{-1}, in the same parameter order and units asfisher.- Return type:
jnp.ndarray, shape (num, N)
Notes
Double precision should be enabled (
jax_enable_x64); in float32 the diagonal rescaling cannot compensate the extreme condition number of the mixed-unit Fisher matrix.The function is compatible with
jax.jit;jax.vmapover the Fisher matrices (with a common seed) draws samples for several parameter sets at once.
- pespace.inference.fisher.wrap_angle_params(samples)[source]¶
Wrap the angle parameters of a sample set into finite canonical ranges.
The following entries of
samplesare wrapped if present; all other entries are left unchanged:ecliptic_longitude: wrapped modulo2*piinto[0, 2*pi);ecliptic_latitude: folded by reflection about the boundaries-pi/2andpi/2into[-pi/2, pi/2];inclination: folded by reflection about the boundaries0andpiinto[0, pi];polarization: wrapped modulopiinto[0, pi)(the detector response depends on the polarization angle through its double angle, sopiis its fundamental period);reference_phase: wrapped modulo2*piinto[0, 2*pi).
These are the finite ranges conventionally used for the angle parameters of the space-borne detector response; they match the sampling ranges adopted in the example scripts.
- Parameters:
samples (mapping) – Mapping from parameter names to sample values, e.g. a
dictof arrays or apandas.DataFrame; values may be scalars or arrays of any array library (Python, NumPy or JAX).- Returns:
A copy of
sampleswith the angle parameters restricted to their finite ranges; neither the input container nor its arrays are modified. The copy is shallow: the wrapped entries are replaced by newly created arrays, while the remaining entries are shared with the input (a deep copy is not needed, since no array is modified in place).- Return type:
mapping
Notes
The wrapping is exact for the periodic angles (
ecliptic_longitude,polarizationandreference_phase) and is a reflection fold for the bounded angles (ecliptic_latitudeandinclination).In this likelihood the
reference_phaseis periodic with periodpirather than2*pi(the strain depends on2 * reference_phase), so the two wells atphiandphi + piare exactly symmetric; the wrapping above keeps the conventional[0, 2*pi)range, and the wells can be identified withreference_phase % piwhen needed.The wrapping is compatible with
jax.jit; the reflection folds usejnp.abs, so those results are JAX arrays even for non-JAX inputs.