diff --git a/src/univariate/discrete/poisson.jl b/src/univariate/discrete/poisson.jl index f6f3bb886..f91499f38 100644 --- a/src/univariate/discrete/poisson.jl +++ b/src/univariate/discrete/poisson.jl @@ -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 @@ -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 diff --git a/test/discrete_test.json b/test/discrete_test.json index bb5a65b21..9f1d9447e 100644 --- a/test/discrete_test.json +++ b/test/discrete_test.json @@ -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)", {