-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testitem "Check `Bernoulli` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return Bernoulli(rand(rng)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testitem "Check `Beta` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return Beta(10rand(rng), 10rand(rng)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testitem "Check `Chisq` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return Chisq(1 + 10rand(rng)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@testitem "Check `Dirichlet` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
k = rand(rng, 2:10) | ||
return Dirichlet(10rand(rng, k)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testitem "Check `Exponential` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return Exponential(100rand(rng)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@testitem "Check `Gamma` natural manifold" begin | ||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return Gamma(10rand(rng), 10rand(rng)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testitem "Check `Geometric` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return Geometric(rand(rng)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testitem "Check `Laplace` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return Laplace(10rand(rng), 10rand(rng)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testitem "Check `LogNormal` natural manifold" begin | ||
|
||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return LogNormal(10randn(rng), 10rand(rng)) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
using StableRNGs, ExponentialFamily, ManifoldsBase, LinearAlgebra | ||
|
||
import ExponentialFamilyManifolds: get_natural_manifold, partition_point | ||
|
||
function test_natural_manifold(f; seed=42, ndistributions=100) | ||
rng = StableRNG(seed) | ||
|
||
foreach(1:ndistributions) do _ | ||
distribution = f(rng) | ||
sample = rand(rng, distribution) | ||
dims = size(sample) | ||
|
||
ef = convert(ExponentialFamilyDistribution, distribution) | ||
T = ExponentialFamily.exponential_family_typetag(ef) | ||
M = get_natural_manifold(T, dims, getconditioner(ef)) | ||
η = partition_point(T, dims, getnaturalparameters(ef), getconditioner(ef)) | ||
|
||
@test is_point(M, η, error=:error) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@testitem "Check `Normal` natural manifold" begin | ||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
return NormalMeanVariance(10randn(rng), 10rand(rng)) | ||
end | ||
end | ||
|
||
@testitem "Check `MvNormal` natural manifold" begin | ||
include("natural_manifolds_setuptests.jl") | ||
|
||
test_natural_manifold() do rng | ||
k = rand(rng, 1:10) | ||
m = randn(k) | ||
L = LowerTriangular(randn(k, k)) | ||
C = L * L' + k * I | ||
return MvNormalMeanCovariance(m, C) | ||
end | ||
end |