Noise log likelihood recomputed at each likelihood call
Currently calling the likelihood.log_likelihood()
during sampling recalculates noise log likelikood at each step:
def noise_log_likelihood(self):
log_l = 0
for interferometer in self.interferometers:
mask = interferometer.frequency_mask
log_l -= noise_weighted_inner_product(
interferometer.frequency_domain_strain[mask],
interferometer.frequency_domain_strain[mask],
interferometer.power_spectral_density_array[mask],
self.waveform_generator.duration) / 2
return float(np.real(log_l))
In most cases it is inconsequential, as it does not invoke calling the waveform generator. But for multi-banded likelihoods, where the data is stored on just a fraction of the frequency points, the time wasted on re-computation can become noticeable (as the noise log likelihood is calculated on unbanded frequency points).
Is there a reason why noise_log_likelihood()
is recomputed at each likelihood call, instead of being pre-computed before sampling? If not, I would suggest changing it, as it is a small and easy change to make.