Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug on isproper of MatrixDirichlet #215

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/distributions/matrix_dirichlet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ end
# Natural parametrization

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

function (::MeanToNatural{MatrixDirichlet})(tuple_of_θ::Tuple{Any})
(α,) = tuple_of_θ
Expand Down
7 changes: 3 additions & 4 deletions test/distributions/matrix_dirichlet_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,14 @@ end
end

for space in (MeanParametersSpace(), NaturalParametersSpace())
@test !isproper(space, MatrixDirichlet, [Inf Inf; Inf 1.0], 1.0)
@test !isproper(space, MatrixDirichlet, [Inf Inf; Inf 1.0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing this test? Just to see if the nothing condition hits?

Copy link
Contributor Author

@Raphael-Tresor Raphael-Tresor Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not wrong, the noting condition will always hit if we add a fourth argument in the function call. So almost all the tests used to check only that. Right?

@test !isproper(space, MatrixDirichlet, [1.0], Inf)
@test !isproper(space, MatrixDirichlet, [NaN], 1.0)
@test !isproper(space, MatrixDirichlet, [NaN],)
@test !isproper(space, MatrixDirichlet, [1.0], NaN)
@test !isproper(space, MatrixDirichlet, [0.5, 0.5], 1.0)
@test isproper(space, MatrixDirichlet, [2.0, 3.0])
@test !isproper(space, MatrixDirichlet, [-1.0, -1.2])
end

end
@test_throws Exception convert(ExponentialFamilyDistribution, MatrixDirichlet([Inf Inf; 2 3]))
end

Expand Down
Loading