Skip to content

Commit d390f64

Browse files
authored
Merge pull request #198 from ReactiveBayes/fix_normal_gamma
Fix isproper function for Normal-Gamma distribution
2 parents 37632ac + fbf414f commit d390f64

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/distributions/normal_gamma.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ BayesBase.support(::Type{NormalGamma}) = NormalGammaDomain()
103103

104104
# Natural parametrization
105105
isproper(::NaturalParametersSpace, ::Type{NormalGamma}, η, conditioner) =
106-
isnothing(conditioner) && length(η) === 4 && getindex(η, 2) < 0 && getindex(η, 3) > -1 / 2 && getindex(η, 4) < 0 && all(!isinf, η) && all(!isnan, η)
106+
isnothing(conditioner) && length(η) === 4 && getindex(η, 2) < 0 && getindex(η, 3) > -1 / 2 && getindex(η, 1)^2/(4*getindex(η,2)) - getindex(η, 4) > 0 && all(!isinf, η) && all(!isnan, η)
107107
isproper(::MeanParametersSpace, ::Type{NormalGamma}, θ, conditioner) =
108108
isnothing(conditioner) && length(θ) === 4 && all(>(0), getindex(θ, 2:4)) && all(!isinf, θ) && all(!isnan, θ)
109109

test/distributions/normal_gamma_tests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ end
3131
end
3232

3333
@test !isproper(MeanParametersSpace(), NormalGamma, [1.0, 0.0, -1.0, 2.0])
34+
@test !isproper(MeanParametersSpace(), NormalGamma, [1.0, 0.0, -1.0, 2.0])
35+
@test !isproper(NaturalParametersSpace(), NormalGamma, [1.0, -0.2, 1.0, -1/0.8 ])
36+
@test !isproper(NaturalParametersSpace(), NormalGamma, [1.0, -0.2, 1.0, 10/8])
37+
@test isproper(NaturalParametersSpace(), NormalGamma, [1.0, -0.2, 1.0, -11/8])
3438
@test !isproper(MeanParametersSpace(), NormalGamma, [-1.0, 0.0, NaN, 1.0], [Inf])
3539
end
3640

0 commit comments

Comments
 (0)