From 48c52af715cc72031e13f946137f7033f492c834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C5=9Een=C3=B6z?= Date: Mon, 8 Jul 2024 12:34:17 +0300 Subject: [PATCH 1/2] add manifold for negative binomial --- src/ExponentialFamilyManifolds.jl | 1 + src/natural_manifolds/negative_binomial.jl | 19 +++++++++++++++++++ .../negative_binomial_tests.jl | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 src/natural_manifolds/negative_binomial.jl create mode 100644 test/natural_manifolds/negative_binomial_tests.jl diff --git a/src/ExponentialFamilyManifolds.jl b/src/ExponentialFamilyManifolds.jl index 19a4ba9..06ffc74 100644 --- a/src/ExponentialFamilyManifolds.jl +++ b/src/ExponentialFamilyManifolds.jl @@ -17,6 +17,7 @@ include("natural_manifolds/geometric.jl") include("natural_manifolds/laplace.jl") include("natural_manifolds/lognormal.jl") include("natural_manifolds/normal.jl") +include("natural_manifolds/negative_binomial.jl") include("natural_manifolds/rayleigh.jl") include("natural_manifolds/pareto.jl") include("natural_manifolds/poisson.jl") diff --git a/src/natural_manifolds/negative_binomial.jl b/src/natural_manifolds/negative_binomial.jl new file mode 100644 index 0000000..cb69d55 --- /dev/null +++ b/src/natural_manifolds/negative_binomial.jl @@ -0,0 +1,19 @@ +""" + get_natural_manifold_base(::Type{NegativeBinomial}, ::Tuple{}, conditioner=nothing) + +Get the natural manifold base for the `NegativeBinomial` distribution. +""" +function get_natural_manifold_base(::Type{NegativeBinomial}, ::Tuple{}, conditioner=nothing) + @assert conditioner >= 0 "Conditioner should be negative" + return Euclidean(1) +end + +""" + partition_point(::Type{NegativeBinomial}, ::Tuple{}, p, conditioner=nothing) + +Converts the `point` to a compatible representation for the natural manifold of type `NegativeBinomial`. +""" +function partition_point(::Type{NegativeBinomial}, ::Tuple{}, p, conditioner=nothing) + @assert conditioner >= 0 "Conditioner should be negative" + return p +end \ No newline at end of file diff --git a/test/natural_manifolds/negative_binomial_tests.jl b/test/natural_manifolds/negative_binomial_tests.jl new file mode 100644 index 0000000..4de3f08 --- /dev/null +++ b/test/natural_manifolds/negative_binomial_tests.jl @@ -0,0 +1,7 @@ +@testitem "Check `NegativeBinomial` natural manifold" begin + include("natural_manifolds_setuptests.jl") + + test_natural_manifold() do rng + return NegativeBinomial(10rand(rng), rand(rng, 0.00001:1)) + end +end \ No newline at end of file From d26b33a63cca40ff3a2bebcf5d5e3e1fcb894cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C5=9Een=C3=B6z?= Date: Mon, 8 Jul 2024 13:49:52 +0300 Subject: [PATCH 2/2] change error message --- src/natural_manifolds/negative_binomial.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/natural_manifolds/negative_binomial.jl b/src/natural_manifolds/negative_binomial.jl index cb69d55..d2920a1 100644 --- a/src/natural_manifolds/negative_binomial.jl +++ b/src/natural_manifolds/negative_binomial.jl @@ -4,7 +4,7 @@ Get the natural manifold base for the `NegativeBinomial` distribution. """ function get_natural_manifold_base(::Type{NegativeBinomial}, ::Tuple{}, conditioner=nothing) - @assert conditioner >= 0 "Conditioner should be negative" + @assert conditioner >= 0 "Conditioner should be non-negative" return Euclidean(1) end