JuliaStats / Distributions.jl

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

fit_mle for Laplace with weights #807

Open yakir12 opened 5 years ago

yakir12 commented 5 years ago

In the docs it looks like fitting Laplace to a dataset with weights would work, but:

n = 100
x = rand(n)
w = rand(n)
fit_mle(Normal, x, w) # works
fit_mle(Laplace, x, w) # doesn't work

errors out with:

ERROR: suffstats is not implemented for (Laplace, Array{Float64,1}, Array{Float64,1}).                 
Stacktrace:
 [1] suffstats(::Type{Laplace}, ::Array{Float64,1}, ::Array{Float64,1}) at /home/yakir/.julia/packages/Distributions/yz3Bc/src/genericfit.jl:5
 [2] fit_mle(::Type{Laplace}, ::Array{Float64,1}, ::Array{Float64,1}) at /home/yakir/.julia/packages/Distributions/yz3Bc/src/genericfit.jl:28
 [3] top-level scope at none:0

I didn't check all the other distributions but there are probably more that don't work with weights. A quick fix might be to change the docs to "only the Normal distribution can be fitted with weights".

matbesancon commented 5 years ago

PR welcome if this is a simple doc change :)