From 03a8e0a1b9c59a3d32d49a0d6632a6d7abfa447a Mon Sep 17 00:00:00 2001 From: Peter Krusche Date: Wed, 5 Oct 2016 19:39:15 +0100 Subject: [PATCH] HAP-240 avoid division by zero --- src/python/Tools/ci.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/python/Tools/ci.py b/src/python/Tools/ci.py index 175cfa6..1e4a1b4 100644 --- a/src/python/Tools/ci.py +++ b/src/python/Tools/ci.py @@ -23,6 +23,10 @@ def jeffreysCI(x, n, alpha=0.05): Brown, Cai and DasGupta: Interval Estimation for a Binomial Proportion. 2001, doi:10.1214/ss/1009213286''' + # HAP-240 avoid division by zero + if n == 0: + return 0.0, 0.0, 1.0 + p = x / n beta = stats.distributions.beta(x+0.5, n-x+0.5)