-
Notifications
You must be signed in to change notification settings - Fork 433
Description
Not a major issue, but I observed inconsistent behaviour on how the binomial and multinomial distributions behave on integer valued floats for the trial number
julia> rand(Binomial(10.0, 0.6))
7but will fail in the equivalent multinomial expression:
julia> rand(Multinomial(10.0, [0.6, 0.4]))
ERROR: MethodError: no method matching Multinomial(::Float64, ::Vector{Float64})
The type `Multinomial` exists, but no method is defined for this combination of argument types when trying to construct it.
Closest candidates are:
Multinomial(::Integer, ::AbstractVector{T}; check_args) where T<:Real
@ Distributions ~/.julia/packages/Distributions/xMnxM/src/multivariate/multinomial.jl:28
Multinomial(::Integer, ::Integer; check_args)
@ Distributions ~/.julia/packages/Distributions/xMnxM/src/multivariate/multinomial.jl:37
Stacktrace:
[1] top-level scope
@ REPL[37]:1I feel they should be consistent. And, in my view, preferably, the multinomial implementation should handle these cases as the binomial version.
Maybe there are specific reasons for the current implementation however that I'm not aware of. There might be similar issues for other distributions; I don't know and did not check systematically.
EDIT:
I found the code for the binomial version on real n to be in scr/deprecates.jl:
function Binomial(n::Real, p::Real)
Base.depwarn("Binomial(n::Real, p) is deprecated. Please use Binomial(n::Integer, p) instead.", :Binomial)
Binomial(Int(n), p)
endHowever, I didn't obtain a deprecation warning on my system (VS code) so that the implementation looked intentional to me..