Skip to content

Commit

Permalink
Add native implementions for Poisson's cdf-like functions
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed May 19, 2021
1 parent eb980aa commit fcaddee
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/distrs/pois.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
import .RFunctions:
# poispdf,
# poislogpdf,
poiscdf,
poisccdf,
poislogcdf,
poislogccdf,
# poiscdf,
# poisccdf,
# poislogcdf,
# poislogccdf,
poisinvcdf,
poisinvccdf,
poisinvlogcdf,
poisinvlogccdf

# generic versions
poispdf::Real, x::Real) = exp(poislogpdf(λ, x))

poislogpdf::T, x::T) where {T <: Real} = xlogy(x, λ) - λ - loggamma(x + 1)

poislogpdf::Real, x::Real) = poislogpdf(promote(float(λ), x)...)

# Just use the Gamma definitions
poiscdf::Real, x::Real) = gammaccdf(floor(x + 1), 1, λ)

poisccdf::Real, x::Real) = gammacdf(floor(x + 1), 1, λ)

poislogcdf::Real, x::Real) = gammalogccdf(floor(x + 1), 1, λ)

poislogccdf::Real, x::Real) = gammalogcdf(floor(x + 1), 1, λ)

0 comments on commit fcaddee

Please sign in to comment.