From 59ff74cb120ea6d53705e82de7a657d8983d3341 Mon Sep 17 00:00:00 2001 From: Marcus P S Date: Mon, 16 Dec 2024 00:12:30 +0000 Subject: [PATCH] Further simplifications following suggestions --- src/univariate/discrete/binomial.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/univariate/discrete/binomial.jl b/src/univariate/discrete/binomial.jl index 950d55c9a..22a9b69cd 100644 --- a/src/univariate/discrete/binomial.jl +++ b/src/univariate/discrete/binomial.jl @@ -78,10 +78,11 @@ function median(dist::Binomial) dist_mean = mean(dist) floor_mean = floor(Int, dist_mean) - - if dist_mean - floor_mean < bound + difference = dist_mean - floor_mean + + if difference < bound floor_mean - elseif floor_mean + 1 - dist_mean < bound + elseif difference > 1 - bound floor_mean + 1 elseif cdf(dist, floor_mean) >= 0.5 floor_mean