Skip to content

Commit

Permalink
Merge pull request JuliaStats#398 from richardreeve/master
Browse files Browse the repository at this point in the history
Fixing Boundary parameter handling JuliaStats#283 for Poisson(0)
  • Loading branch information
johnmyleswhite committed Aug 4, 2015
2 parents 2457917 + b9b0b9c commit 8c52fa6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/univariate/discrete/poisson.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
immutable Poisson <: DiscreteUnivariateDistribution
λ::Float64

Poisson::Real) = (@check_args(Poisson, λ > zero(λ)); new(λ))
Poisson::Real) = (@check_args(Poisson, λ >= zero(λ)); new(λ))
Poisson() = new(1.0)
end

@distr_support Poisson 0 Inf
@distr_support Poisson 0 (d.λ == 0.0 ? 0 : Inf)


### Parameters
Expand Down Expand Up @@ -34,7 +34,9 @@ kurtosis(d::Poisson) = 1.0 / d.λ

function entropy(d::Poisson)
λ = rate(d)
if λ < 50.0
if λ == 0.0
return 0.0
elseif λ < 50.0
s = 0.0
λk = 1.0
for k = 1:100
Expand Down
27 changes: 27 additions & 0 deletions test/discrete_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,33 @@
"var": 1.0
}
],
[
"Poisson(0.0)",
{
"dtype": "Poisson",
"entropy": 0.0,
"maximum": 0,
"mean": 0.0,
"median": 0.0,
"minimum": 0,
"params": {
"rate": 0.0
},
"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
}
],
[
"Poisson(0.5)",
{
Expand Down

0 comments on commit 8c52fa6

Please sign in to comment.