Skip to content

Commit

Permalink
Allow for rate to be 0 in Poisson distribution, everything worked alr…
Browse files Browse the repository at this point in the history
…eady except entropy (which is corrected to 0) and maximum (which is corrected to 0).
  • Loading branch information
richardreeve committed Jul 31, 2015
1 parent 816090c commit 2c78ee9
Showing 1 changed file with 5 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
Expand Up @@ -2,15 +2,15 @@ immutable Poisson <: DiscreteUnivariateDistribution
λ::Float64

function Poisson::Float64)
λ > 0.0 || error("λ must be positive.")
λ >= 0.0 || error("λ must be non-negative.")
new(λ)
end

@compat Poisson::Real) = Poisson(Float64(λ))
Poisson() = new(1.0)
end

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


### Parameters
Expand Down Expand Up @@ -39,7 +39,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

0 comments on commit 2c78ee9

Please sign in to comment.