Skip to content

Commit

Permalink
Hypergeometric: allow n to take 0 and ns+nf values
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Feb 9, 2016
1 parent 3672554 commit 925d6f5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/univariate/discrete/hypergeometric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ immutable Hypergeometric <: DiscreteUnivariateDistribution

function Hypergeometric(ns::Real, nf::Real, n::Real)
@check_args(Hypergeometric, ns >= zero(ns) && nf >= zero(nf))
@check_args(Hypergeometric, zero(n) < n < ns + nf)
@check_args(Hypergeometric, zero(n) <= n <= ns + nf)
new(ns, nf, n)
end
end
Expand Down
50 changes: 50 additions & 0 deletions test/discrete_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,56 @@
"var": 0.35999999999999999
}
],
[
"Hypergeometric(3, 2, 0)",
{
"dtype": "Hypergeometric",
"entropy": 0.0,
"minimum": 0,
"maximum": 0,
"mean": 0,
"median": 0.0,
"params": {},
"points": [
{
"cdf": 1.0,
"logpdf": 0.0,
"x": 0
}
],
"q10": 0.0,
"q25": 0.0,
"q50": 0.0,
"q75": 0.0,
"q90": 0.0,
"var": 0.0
}
],
[
"Hypergeometric(3, 2, 5)",
{
"dtype": "Hypergeometric",
"entropy": 0.0,
"minimum": 3,
"maximum": 3,
"mean": 3.0,
"median": 3.0,
"params": {},
"points": [
{
"cdf": 1.0,
"logpdf": 0.0,
"x": 3
}
],
"q10": 3.0,
"q25": 3.0,
"q50": 3.0,
"q75": 3.0,
"q90": 3.0,
"var": 0.0
}
],
[
"Hypergeometric(4, 5, 6)",
{
Expand Down
2 changes: 2 additions & 0 deletions test/discrete_test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Geometric(0.9)

Hypergeometric(2, 2, 2)
Hypergeometric(3, 2, 2)
Hypergeometric(3, 2, 0)
Hypergeometric(3, 2, 5)
Hypergeometric(4, 5, 6)
Hypergeometric(60, 80, 100)

Expand Down

0 comments on commit 925d6f5

Please sign in to comment.