GWForge.fisher.dali

Doublet-DALI likelihood and posterior sampling.

At order = 1 the log-likelihood is exactly quadratic, so the Fisher posterior is Gaussian and \(\Sigma = F^{-1}\) describes it completely – every marginal is an ellipse available in closed form.

The doublet adds cubic and quartic terms,

\[\log L = -\tfrac{1}{2}F_{ab}\Delta^a\Delta^b - \tfrac{1}{2}G_{abc}\Delta^a\Delta^b\Delta^c - \tfrac{1}{8}H_{abcd}\Delta^a\Delta^b\Delta^c\Delta^d,\]

which has neither a closed-form normalisation nor closed-form marginals.

The contractions are written as flattened matrix products rather than numpy.einsum() so they reach BLAS: measured at 1.9 million evaluations per second versus 0.03 million for the equivalent einsum call.

Attributes

Classes

DALILikelihood

Doublet-DALI log-likelihood as a bilby likelihood.

Functions

build_priors(prior_file, names, fiducial[, ...])

Load and validate the sampling priors.

sample_posterior(likelihood, priors, outdir, label[, ...])

Sample a DALI posterior through bilby.

Module Contents

GWForge.fisher.dali.PHYSICAL_RANGES[source]
class GWForge.fisher.dali.DALILikelihood(fisher, order=2)[source]

Bases: bilby.core.likelihood.Likelihood

Doublet-DALI log-likelihood as a bilby likelihood.

Examples

>>> likelihood = DALILikelihood(fisher)
>>> result = sample_posterior(likelihood, priors, outdir="out", label="src0")
Variables:
  • names (list of str) – Parameter names, in tensor order.

  • fiducial (dict) – The point the expansion is about; samples are offsets from it.

names[source]
fiducial[source]
order = 2[source]
log_likelihood(parameters=None)[source]

Log-likelihood at parameters (or at self.parameters).

Parameters:

parameters (dict or None) – Absolute parameter values, not offsets. Accepting them as an argument is the bilby 3 interface; bilby 2 still sets self.parameters instead, and both work here.

Return type:

float

log_likelihood_from_offsets(offsets)[source]

Vectorised log-likelihood for a stack of parameter offsets.

Parameters:

offsets (numpy.ndarray) – (n_points, n_parameters) displacements from the fiducial point.

Returns:

(n_points,) log-likelihood values.

Return type:

numpy.ndarray

noise_log_likelihood()[source]

Zero: the expansion is about the maximum, where the residual vanishes.

GWForge.fisher.dali.NARROW_PRIOR_SIGMAS = 3.0[source]
GWForge.fisher.dali.build_priors(prior_file, names, fiducial, enforce_physicality=False, sigmas=None)[source]

Load and validate the sampling priors.

Parameters:
  • prior_file (str) – Path to a bilby .prior file.

  • names (sequence of str) – Fisher parameter names that must all be covered.

  • fiducial (dict) – Fiducial values, checked to lie inside the prior support – a prior that excludes the point the expansion is about would be sampling nothing.

  • enforce_physicality (bool) – Also reject samples outside PHYSICAL_RANGES.

  • sigmas (dict or None) – Fisher one-sigma widths. When given, priors narrower than NARROW_PRIOR_SIGMAS sigmas are warned about.

Return type:

bilby.core.prior.PriorDict

Raises:
  • KeyError – If the file does not define every parameter. bilby’s own prior files use mass_ratio, a_1 and friends, which do not line up with the default Fisher parameters, so this is a likely mistake and is worth failing loudly for rather than silently sampling the wrong space.

  • ValueError – If a fiducial value falls outside its prior.

GWForge.fisher.dali.sample_posterior(likelihood, priors, outdir, label, sampler='emcee', nwalkers=200, nsteps=2000, nburn=500, **kwargs)[source]

Sample a DALI posterior through bilby.

Parameters:
  • likelihood (DALILikelihood)

  • priors (bilby.core.prior.PriorDict)

  • outdir (str) – Output directory for the sampler.

  • label (str) – Run label, used for the output filenames.

  • sampler (str) – Any bilby sampler; emcee by default.

  • nwalkers (int) – emcee settings, ignored by nested samplers.

  • nsteps (int) – emcee settings, ignored by nested samplers.

  • nburn (int) – emcee settings, ignored by nested samplers.

  • **kwargs – Passed straight to bilby.run_sampler().

Return type:

bilby.core.result.Result