bilby.gw.likelihood.relative.RelativeBinningGravitationalWaveTransient

class bilby.gw.likelihood.relative.RelativeBinningGravitationalWaveTransient(interferometers, waveform_generator, fiducial_parameters=None, parameter_bounds=None, maximization_kwargs=None, update_fiducial_parameters=False, distance_marginalization=False, time_marginalization=False, phase_marginalization=False, priors=None, distance_marginalization_lookup_table=None, jitter_time=True, reference_frame='sky', time_reference='geocenter', chi=1, epsilon=0.5)[source]

Bases: GravitationalWaveTransient

A gravitational-wave transient likelihood object which uses the relative binning procedure to calculate a fast likelihood. See Zackay et al. arXiv1806.08792

Parameters:
interferometers: list, bilby.gw.detector.InterferometerList

A list of bilby.detector.Interferometer instances - contains the detector data and power spectral densities

waveform_generator: `bilby.waveform_generator.WaveformGenerator`

An object which computes the frequency-domain strain of the signal, given some set of parameters

fiducial_parameters: dict, optional

A starting guess for initial parameters of the event for finding the maximum likelihood (fiducial) waveform. These should be specified in the same parameter basis as the one that sampling is carried out in. For example, if sampling in mass_1 and mass_2, the fiducial parameters should also be provided in mass_1 and mass_2.

parameter_bounds: dict, optional

Dictionary of bounds (lists) for the initial parameters when finding the initial maximum likelihood (fiducial) waveform.

distance_marginalization: bool, optional

If true, marginalize over distance in the likelihood. This uses a look up table calculated at run time. The distance prior is set to be a delta function at the minimum distance allowed in the prior being marginalised over.

time_marginalization: bool, optional

If true, marginalize over time in the likelihood. This uses a FFT to calculate the likelihood over a regularly spaced grid. In order to cover the whole space the prior is set to be uniform over the spacing of the array of times. If using time marginalisation and jitter_time is True a “jitter” parameter is added to the prior which modifies the position of the grid of times.

phase_marginalization: bool, optional

If true, marginalize over phase in the likelihood. This is done analytically using a Bessel function. The phase prior is set to be a delta function at phase=0.

priors: dict, optional

If given, used in the distance and phase marginalization.

distance_marginalization_lookup_table: (dict, str), optional

If a dict, dictionary containing the lookup_table, distance_array, (distance) prior_array, and reference_distance used to construct the table. If a string the name of a file containing these quantities. The lookup table is stored after construction in either the provided string or a default location: ‘.distance_marginalization_lookup_dmin{}_dmax{}_n{}.npz’

jitter_time: bool, optional

Whether to introduce a time_jitter parameter. This avoids either missing the likelihood peak, or introducing biases in the reconstructed time posterior due to an insufficient sampling frequency. Default is False, however using this parameter is strongly encouraged.

reference_frame: (str, bilby.gw.detector.InterferometerList, list), optional

Definition of the reference frame for the sky location. - “sky”: sample in RA/dec, this is the default - e.g., “H1L1”, [“H1”, “L1”], InterferometerList([“H1”, “L1”]):

sample in azimuth and zenith, azimuth and zenith defined in the frame where the z-axis is aligned the the vector connecting H1 and L1.

time_reference: str, optional

Name of the reference for the sampled time parameter. - “geocent”/”geocenter”: sample in the time at the Earth’s center,

this is the default

  • e.g., “H1”: sample in the time of arrival at H1

chi: float, optional

Tunable parameter which limits the perturbation of alpha when setting up the bin range. See https://arxiv.org/abs/1806.08792.

epsilon: float, optional

Tunable parameter which limits the differential phase change in each bin when setting up the bin range. See https://arxiv.org/abs/1806.08792.

Returns:
Likelihood: bilby.core.likelihood.Likelihood

A likelihood object, able to compute the likelihood of the data given some model parameters.

Notes

The relative binning likelihood does not currently support calibration marginalization.

__init__(interferometers, waveform_generator, fiducial_parameters=None, parameter_bounds=None, maximization_kwargs=None, update_fiducial_parameters=False, distance_marginalization=False, time_marginalization=False, phase_marginalization=False, priors=None, distance_marginalization_lookup_table=None, jitter_time=True, reference_frame='sky', time_reference='geocenter', chi=1, epsilon=0.5)[source]

Empty likelihood class to be subclassed by other likelihoods

Parameters:
parameters: dict

A dictionary of the parameter names and associated values

__call__(*args, **kwargs)

Call self as a function.

Methods

__init__(interferometers, waveform_generator)

Empty likelihood class to be subclassed by other likelihoods

cache_lookup_table()

calculate_snrs(waveform_polarizations, ...)

Compute the snrs

calibration_marginalized_likelihood(...)

compute_log_likelihood_from_snrs(total_snrs)

compute_per_detector_log_likelihood()

compute_summary_data()

compute_waveform_ratio_per_interferometer(...)

distance_marginalized_likelihood(d_inner_h, ...)

find_maximum_likelihood_parameters(...[, ...])

generate_calibration_sample_from_marginalized_likelihood([...])

Generate a single sample from the posterior distribution for the set of calibration response curves when explicitly marginalizing over the calibration uncertainty.

generate_distance_sample_from_marginalized_likelihood([...])

Generate a single sample from the posterior distribution for luminosity distance when using a likelihood which explicitly marginalises over distance.

generate_phase_sample_from_marginalized_likelihood([...])

Generate a single sample from the posterior distribution for phase when using a likelihood which explicitly marginalises over phase.

generate_posterior_sample_from_marginalized_likelihood()

Reconstruct the distance posterior from a run which used a likelihood which explicitly marginalised over time/distance/phase.

generate_time_sample_from_marginalized_likelihood([...])

Generate a single sample from the posterior distribution for coalescence time when using a likelihood which explicitly marginalises over time.

get_bounds_from_priors(priors)

get_calibration_log_likelihoods([...])

get_parameter_dictionary_from_list(...)

get_parameter_list_from_dictionary(...)

get_sky_frame_parameters([parameters])

Generate ra, dec, and geocenter time for parameters

lnlike_scipy_maximize(parameter_list)

load_lookup_table(filename)

log_likelihood()

log_likelihood_ratio()

Difference between log likelihood and noise log likelihood

noise_log_likelihood()

phase_marginalized_likelihood(d_inner_h, ...)

set_fiducial_waveforms(parameters)

setup_bins()

Setup the frequency bins following the method in https://arxiv.org/abs/1806.08792.

time_marginalized_likelihood(...)

Attributes

cached_lookup_table_filename

interferometers

lal_version

lalsimulation_version

marginalized_parameters

meta_data

priors

reference_frame

calculate_snrs(waveform_polarizations, interferometer, return_array=True)[source]

Compute the snrs

Parameters:
waveform_polarizations: dict

A dictionary of waveform polarizations and the corresponding array

interferometer: bilby.gw.detector.Interferometer

The bilby interferometer object

return_array: bool

If true, calculate and return internal array objects (d_inner_h_array and optimal_snr_squared_array), otherwise these are returned as None.

Returns:
calculated_snrs: _CalculatedSNRs

An object containing the SNR quantities and (if return_array=True) the internal array objects.

generate_calibration_sample_from_marginalized_likelihood(signal_polarizations=None)[source]

Generate a single sample from the posterior distribution for the set of calibration response curves when explicitly marginalizing over the calibration uncertainty.

Parameters:
signal_polarizations: dict, optional

Polarizations modes of the template.

Returns:
new_calibration: dict

Sample set from the calibration posterior

generate_distance_sample_from_marginalized_likelihood(signal_polarizations=None)[source]

Generate a single sample from the posterior distribution for luminosity distance when using a likelihood which explicitly marginalises over distance.

See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293

Parameters:
signal_polarizations: dict, optional

Polarizations modes of the template. Note: These are rescaled in place after the distance sample is generated to allow further parameter reconstruction to occur.

Returns:
new_distance: float

Sample from the distance posterior.

generate_phase_sample_from_marginalized_likelihood(signal_polarizations=None)[source]

Generate a single sample from the posterior distribution for phase when using a likelihood which explicitly marginalises over phase.

See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293

Parameters:
signal_polarizations: dict, optional

Polarizations modes of the template.

Returns:
new_phase: float

Sample from the phase posterior.

Notes

This is only valid when assumes that mu(phi) propto exp(-2i phi).

generate_posterior_sample_from_marginalized_likelihood()[source]

Reconstruct the distance posterior from a run which used a likelihood which explicitly marginalised over time/distance/phase.

See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293

Returns:
sample: dict

Returns the parameters with new samples.

Notes

This involves a deepcopy of the signal to avoid issues with waveform caching, as the signal is overwritten in place.

generate_time_sample_from_marginalized_likelihood(signal_polarizations=None)[source]

Generate a single sample from the posterior distribution for coalescence time when using a likelihood which explicitly marginalises over time.

In order to resolve the posterior we artificially upsample to 16kHz.

See Eq. (C29-C32) of https://arxiv.org/abs/1809.02293

Parameters:
signal_polarizations: dict, optional

Polarizations modes of the template.

Returns:
new_time: float

Sample from the time posterior.

get_sky_frame_parameters(parameters=None)[source]

Generate ra, dec, and geocenter time for parameters

This method will attempt to convert from the reference time and sky parameters, but if they are not present it will fall back to ra and dec.

Parameters:
parameters: dict, optional

The parameters to be converted. If not specified self.parameters will be used.

Returns:
dict: dictionary containing ra, dec, and geocent_time
log_likelihood()[source]
Returns:
float
log_likelihood_ratio()[source]

Difference between log likelihood and noise log likelihood

Returns:
float
noise_log_likelihood()[source]
Returns:
float
setup_bins()[source]

Setup the frequency bins following the method in https://arxiv.org/abs/1806.08792.

If epsilon is too small, the naive bins can be smaller than the frequency spacing of the data. We require that bins are at least as wide as this spacing.