From d8b9b4b7c07d2d2b48144f6c73239832d7a327ec Mon Sep 17 00:00:00 2001 From: Kipp Cannon <kcannon@cita.utoronto.ca> Date: Thu, 12 Apr 2018 02:08:41 +0900 Subject: [PATCH] NumeratorSNRCHIPDF: preserve histogram count in .__iadd__() - the count is meaningless, it is only used to set the scale of the density estimation kernel, but for that reason it should not change as the result of addition operations - in the current pipeline care is taken to never add more than a single copy of the numerator into any ranking statistic in order to control the total count - this patch causes .__iadd__() to preserve the total count, allowing the analysis pipeline plumbing to be simplified since there is no reason to fear adding multiple copies of the numerator together --- gstlal-inspiral/python/stats/inspiral_extrinsics.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gstlal-inspiral/python/stats/inspiral_extrinsics.py b/gstlal-inspiral/python/stats/inspiral_extrinsics.py index dfff5b29cd..19cb07e881 100644 --- a/gstlal-inspiral/python/stats/inspiral_extrinsics.py +++ b/gstlal-inspiral/python/stats/inspiral_extrinsics.py @@ -857,7 +857,16 @@ class NumeratorSNRCHIPDF(rate.BinnedLnPDF): raise NotImplementedError def __iadd__(self, other): + # the total count is meaningless, it serves only to set the + # scale by which the density estimation kernel chooses its + # size, so we preserve the count across this operation. if + # the two arguments have different counts, use the + # geometric mean unless one of the two is 0 in which case + # don't screw with the total count + self_count, other_count = self.array.sum(), other.array.sum() super(rate.BinnedLnPDF, self).__iadd__(other) + if self_count and other_count: + self.array *= numpy.exp((numpy.log(self_count) + numpy.log(other_count)) / 2.) / self.array.sum() self.norm = numpy.log(numpy.exp(self.norm) + numpy.exp(other.norm)) return self -- GitLab