JuliaStats / Distributions.jl

A Julia package for probability distributions and associated functions.
Other
1.08k stars 410 forks source link

MLE fit Poisson - just doc? #1748

Open i9e1 opened 12 months ago

i9e1 commented 12 months ago

Hi all,

fitting data to a Poisson distribution does not work as stated in the doc of fit_mle.

with v0.25.95 and v0.25.98

julia> x = [0.3721095631823048, 0.4327034042239485, 0.43291359831536913, 0.445593656578241, 0.48362128879102395, 0.49802749585289674, 0.5108398733043521, 0.5111593012581018, 0.5257297049959202, 0.5346582549277084];

julia> fit_mle(Poisson, x)
ERROR: suffstats is not implemented for (Poisson, Vector{Float64}).
Stacktrace:
 [1] suffstats(dt::Type{Poisson}, xs::Vector{Float64})
   @ Distributions ~/.julia/packages/Distributions/GrN7f/src/genericfit.jl:5
 [2] fit_mle(dt::Type{Poisson}, x::Vector{Float64})
   @ Distributions ~/.julia/packages/Distributions/GrN7f/src/genericfit.jl:27
 [3] top-level scope
   @ REPL[1292]:1

Other (continous) distributions I tested worked as espected (Normal, LogNormal, Gamma, Weibull, Laplace). Am I doing something wrong, is there an error in the doc or was somewhere back in history a braking chance on either the Poisson or fit_mle?

skleinbo commented 10 months ago

A Poisson distribution describes counts. You can fit it on non-negative integers (Distributions.jl@0.25.95)

julia> x = rand(0:10, 10);

julia> fit(Poisson, x)
Poisson{Float64}(λ=3.2)