From 0b51f18d4204cf1a0562b8376fa3c1c49270b34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C5=9Een=C3=B6z?= Date: Thu, 20 Jun 2024 17:08:09 +0200 Subject: [PATCH] add normal gamma manifolds --- src/ExponentialFamilyManifolds.jl | 1 + src/natural_manifolds/normal_gamma.jl | 19 +++++++++++++++++++ test/natural_manifolds/normal_gamma_tests.jl | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 src/natural_manifolds/normal_gamma.jl create mode 100644 test/natural_manifolds/normal_gamma_tests.jl diff --git a/src/ExponentialFamilyManifolds.jl b/src/ExponentialFamilyManifolds.jl index 80fee8d..686cef3 100644 --- a/src/ExponentialFamilyManifolds.jl +++ b/src/ExponentialFamilyManifolds.jl @@ -17,5 +17,6 @@ include("natural_manifolds/geometric.jl") include("natural_manifolds/laplace.jl") include("natural_manifolds/lognormal.jl") include("natural_manifolds/normal.jl") +include("natural_manifolds/normal_gamma.jl") end diff --git a/src/natural_manifolds/normal_gamma.jl b/src/natural_manifolds/normal_gamma.jl new file mode 100644 index 0000000..facaf3f --- /dev/null +++ b/src/natural_manifolds/normal_gamma.jl @@ -0,0 +1,19 @@ +""" + get_natural_manifold_base(::Type{NormalGamma}, ::Tuple{}, conditioner=nothing) + +Get the natural manifold base for the `NormalGamma` distribution. +""" +function get_natural_manifold_base(::Type{NormalGamma}, ::Tuple{Int}, conditioner=nothing) + return ProductManifold( + Euclidean(1), ShiftedNegativeNumbers(static(0)), ShiftedPositiveNumbers(static(-1/2)),ShiftedNegativeNumbers(static(0)) + ) +end + +""" + partition_point(::Type{NormalGamma}, ::Tuple{}, p, conditioner=nothing) + +Converts the `point` to a compatible representation for the natural manifold of type `NormalGamma`. +""" +function partition_point(::Type{NormalGamma}, ::Tuple{Int}, p, conditioner=nothing) + return ArrayPartition(view(p, 1:1), view(p, 2:2), view(p, 3:3), view(p, 4:4)) +end \ No newline at end of file diff --git a/test/natural_manifolds/normal_gamma_tests.jl b/test/natural_manifolds/normal_gamma_tests.jl new file mode 100644 index 0000000..574140b --- /dev/null +++ b/test/natural_manifolds/normal_gamma_tests.jl @@ -0,0 +1,7 @@ +@testitem "Check `NormalGamma` natural manifold" begin + include("natural_manifolds_setuptests.jl") + + test_natural_manifold() do rng + return NormalGamma(10rand(rng), 10rand(rng), 10rand(rng), 10rand(rng)) + end +end \ No newline at end of file