Skip to content

Commit

Permalink
Vector with NaN is improper Dirichlet in natural parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterwln committed Jan 8, 2025
1 parent 09a57f6 commit e1c916d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/distributions/dirichlet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function BayesBase.insupport(ef::ExponentialFamilyDistribution{Dirichlet}, x)
end
# Natural parametrization

isproper(::NaturalParametersSpace, ::Type{Dirichlet}, η, conditioner) = isnothing(conditioner) && length(η) > 1 && all(isless.(-1, η)) && all(!isinf, η)
isproper(::NaturalParametersSpace, ::Type{Dirichlet}, η, conditioner) =
isnothing(conditioner) && length(η) > 1 && all(isless.(-1, η)) && all(!isinf, η) && all(!isnan, η)
isproper(::MeanParametersSpace, ::Type{Dirichlet}, θ, conditioner) = isnothing(conditioner) && length(θ) > 1 && all(>(0), θ) && all(!isinf, θ)

function (::MeanToNatural{Dirichlet})(tuple_of_θ::Tuple{Any})
Expand Down
1 change: 1 addition & 0 deletions test/distributions/dirichlet_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ end
@test !isproper(space, Dirichlet, [0.5, 0.5], 1.0)
@test isproper(space, Dirichlet, [2.0, 3.0])
@test !isproper(space, Dirichlet, [-1.0, -1.2])
@test !isproper(space, Dirichlet, [NaN, 1.0, 1.0])
end

@test_throws Exception convert(ExponentialFamilyDistribution, Dirichlet([Inf, Inf]))
Expand Down

0 comments on commit e1c916d

Please sign in to comment.