# Problem with fitting Beta distribution

**URL:** <https://discourse.julialang.org/t/problem-with-fitting-beta-distribution/64719>\
**Category:** General Usage\
**Tags:** question, package, distributions\
**Created:** [July 15, 2021, 10:15pm UTC](https://discourse.julialang.org/t/problem-with-fitting-beta-distribution/64719 "2021-07-15T22:15:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taylor\_Dinkins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/taylor_dinkins/32/27177_2.png) [@Taylor\_Dinkins](https://discourse.julialang.org/u/Taylor_Dinkins)\
**Post date:** [July 15, 2021, 10:15pm UTC](https://discourse.julialang.org/t/problem-with-fitting-beta-distribution/64719/1 "2021-07-15T22:15:46Z")

</div>

Trying to do a simple distribution fitting with Distributions package throws me an error. I’ve been able to get it working with various other distributions, including Dirichlet and Binomial, but can’t for Beta. I’m doing:

```julia
k = rand(Beta(1.0, 1.0), 10)
fit_mle(Beta, k)

```

Which throws me the error:

```julia
suffstats is not implemented for (Beta, Vector{Float64}).

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] suffstats(dt::Type{Beta}, xs::Vector{Float64})
   @ Distributions ~/.julia/packages/Distributions/HjzA0/src/genericfit.jl:5
 [3] fit_mle(dt::Type{Beta}, x::Vector{Float64})
   @ Distributions ~/.julia/packages/Distributions/HjzA0/src/genericfit.jl:27
 [4] top-level scope
   @ In[154]:5
 [5] eval
   @ ./boot.jl:360 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1116

```

I read through an example of this on Poisson data, but my data type is correct as far as I know, given it was sampled from Beta.

Thanks everyone!

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 15, 2021, 10:18pm UTC](https://discourse.julialang.org/t/problem-with-fitting-beta-distribution/64719/2 "2021-07-15T22:18:08Z")

</div>

> <https://github.com/JuliaStats/Distributions.jl/issues/1063>
>
> \`fit\_mle(Beta, rand(10))\` gives \`ERROR: suffstats is not implemented for (Beta, …Array{Float64,1}).\`
> 
> I checked the source code and found there is a \`fit\` function implemented, but it doesn't take weights. 
> 
> The \[docs\](https://juliastats.org/Distributions.jl/stable/fit/) explicitly say that \`fit\_mle\` has been implemented for \`Beta\`.
