Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/univariate/discrete/binomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ function mode(d::Binomial{T}) where T<:Real
end
modes(d::Binomial) = Int[mode(d)]

median(d::Binomial) = round(Int,mean(d))

function skewness(d::Binomial)
n, p1 = params(d)
p0 = 1 - p1
Expand Down
2 changes: 1 addition & 1 deletion test/ref/discrete/binomial.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Binomial <- R6Class("Binomial",
failprob=q,
ntrials=n,
mean=n * p,
median=round(n * p),
median=qbinom(0.5, self$n, self$p),
var=n * p * q,
skewness=(q - p) / sqrt(n*p*q),
kurtosis=(1 - 6*p*q) / (n*p*q))
Expand Down
2 changes: 1 addition & 1 deletion test/ref/discrete_test.ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
"failprob": 0.5,
"ntrials": 3,
"mean": 1.5,
"median": 2,
"median": 1,
"var": 0.75,
"skewness": 0,
"kurtosis": -0.666666666666667
Expand Down
7 changes: 7 additions & 0 deletions test/univariate/discrete/binomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ end
@test Distributions.expectation(identity, Binomial(6)) ≈ 3.0
@test Distributions.expectation(x -> -x, Binomial(10, 0.2)) ≈ -2.0

# Test median
@test median(Binomial(5,3//10)) == 1
@test median(Binomial(25,3//10)) == 7
@test median(Binomial(45,3//10)) == 13
@test median(Binomial(65,3//10)) == 19
@test median(Binomial(85,3//10)) == 25

# Test mode
@test Distributions.mode(Binomial(100, 0.4)) == 40
@test Distributions.mode(Binomial(1, 0.51)) == 1
Expand Down
Loading