Problem with Poisson distribution fitting of an array of floats (suffstats is not implemented for (Poisson, Array{Float64,1}))

Hi, I’m currently working in Windows 10 with Julia 1.5.3 in a Jupyter notebook, using Distributions.

I have an array of type Array{Float64,1} called “derivadas_reales_desplazado”. I want to fit a Poisson distribution to this array of data, but when I type:

fit_mle(Poisson, derivadas_reales_desplazado)
or
Distributions.fit_mle(Distributions.Poisson, derivadas_reales_desplazado)

it outputs the following issue:

suffstats is not implemented for (Poisson, Array{Float64,1}).

The values of “derivadas_reales_desplazado” are in the (0,1) interval, so there should be no problem fitting a Poisson distribution to it.
I also find this curious since fit_mle(Normal, derivadas_reales_desplazado) works fine.
Andy help will be truly appreciated.

I think fit(Poisson, data) expects your data to be Boolean or 0/1 integers:

julia> using Distributions

julia> fit(Poisson, rand(0:1, 100))
Poisson{Float64}(λ=0.56)

julia> fit(Poisson, rand([0.0, 1.0], 100))
ERROR: suffstats is not implemented for (Poisson, Vector{Float64}).
1 Like

The support of Poisson is natural numbers so any positive integers will do. You could use round.(Int, derivadas_reales_desplazado) to convert to Int but if your numbers are float between 0 and 1 that doesn’t make much sense, and you probably want to use another distribution (e.g. Beta).

1 Like

Right! Than you very much.