diff --git a/src/univariate/discrete/bernoulli.jl b/src/univariate/discrete/bernoulli.jl index e784452f8..42a5ac275 100644 --- a/src/univariate/discrete/bernoulli.jl +++ b/src/univariate/discrete/bernoulli.jl @@ -35,11 +35,7 @@ function modes(d::Bernoulli) p > 0.5 ? [1] : [0, 1] end -function median(d::Bernoulli) - p = succprob(d) - p < 0.5 ? 0.0 : - p > 0.5 ? 1.0 : 0.5 -end +median(d::Bernoulli) = ifelse(succprob(d) <= 0.5, 0, 1) function entropy(d::Bernoulli) p0 = failprob(d) diff --git a/test/discrete_test.json b/test/discrete_test.json index f54eecf76..f71853ddb 100644 --- a/test/discrete_test.json +++ b/test/discrete_test.json @@ -6,7 +6,7 @@ "entropy": 0.69314718055994529, "maximum": 1, "mean": 0.5, - "median": 0.5, + "median": 0, "minimum": 0, "params": { "failprob": 0.5, @@ -24,11 +24,11 @@ "x": 1 } ], - "q10": 0.0, - "q25": 0.0, - "q50": 0.0, - "q75": 1.0, - "q90": 1.0, + "q10": 0, + "q25": 0, + "q50": 0, + "q75": 1, + "q90": 1, "var": 0.25 } ], @@ -39,7 +39,7 @@ "entropy": 0.56233514461880829, "maximum": 1, "mean": 0.25, - "median": 0.0, + "median": 0, "minimum": 0, "params": { "failprob": 0.75, @@ -57,11 +57,11 @@ "x": 1 } ], - "q10": 0.0, - "q25": 0.0, - "q50": 0.0, - "q75": 0.0, - "q90": 1.0, + "q10": 0, + "q25": 0, + "q50": 0, + "q75": 0, + "q90": 1, "var": 0.1875 } ], @@ -72,7 +72,7 @@ "entropy": 0.56233514461880829, "maximum": 1, "mean": 0.75, - "median": 1.0, + "median": 1, "minimum": 0, "params": { "failprob": 0.25, @@ -90,11 +90,11 @@ "x": 1 } ], - "q10": 0.0, - "q25": 0.0, - "q50": 1.0, - "q75": 1.0, - "q90": 1.0, + "q10": 0, + "q25": 0, + "q50": 1, + "q75": 1, + "q90": 1, "var": 0.1875 } ],