From ddf70317dc92b594b15bc584274929356ee6b37e Mon Sep 17 00:00:00 2001
From: Kipp Cannon <kipp.cannon@ligo.org>
Date: Tue, 16 Aug 2016 18:29:03 +0900
Subject: [PATCH] gstlal.stats: add poisson_ln_p_0()

---
 gstlal/python/stats/__init__.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gstlal/python/stats/__init__.py b/gstlal/python/stats/__init__.py
index d58d2d96c6..1ff6c3bdd2 100644
--- a/gstlal/python/stats/__init__.py
+++ b/gstlal/python/stats/__init__.py
@@ -123,6 +123,17 @@ def assert_probability(f):
 	return g
 
 
+def assert_ln_probability(f):
+	def g(*args, **kwargs):
+		p = f(*args, **kwargs)
+		if isinstance(p, numpy.ndarray):
+			assert (p <= 0.).all()
+		else:
+			assert p <= 0.
+		return p
+	return g
+
+
 @assert_probability
 @numpy.vectorize
 def poisson_p_not_0(l):
@@ -178,6 +189,15 @@ def poisson_p_0(l):
 	return numpy.exp(-l)
 
 
+@assert_ln_probability
+def poisson_ln_p_0(l):
+	"""
+	Return the natural logarithm of the probability that a Poisson
+	process with a mean rate of l yields a zero count.  = -l.
+	"""
+	return -l
+
+
 #
 # =============================================================================
 #
-- 
GitLab