From aaf62bf4a5f13b6a6f0479f754d48f4ff9eedd07 Mon Sep 17 00:00:00 2001 From: Bart van Erp <44952318+bartvanerp@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:59:26 +0200 Subject: [PATCH] add tests poisson --- test/distributions/poisson_tests.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/distributions/poisson_tests.jl b/test/distributions/poisson_tests.jl index 775115e..4c44e30 100644 --- a/test/distributions/poisson_tests.jl +++ b/test/distributions/poisson_tests.jl @@ -1,6 +1,6 @@ @testitem "Poisson distribution" begin - using UnboundedBNN: Poisson, SafePoisson, mean, var, std, cdf, pdf, pmf, logpmf, KL_loss, get_λ, realtype, TruncatedDistribution + using UnboundedBNN: Poisson, SafePoisson, mean, var, std, cdf, invcdf, pdf, pmf, logpmf, KL_loss, get_λ, realtype, TruncatedDistribution construct_safepoisson(λ) = SafePoisson([invsoftplus(λ)]) @@ -55,6 +55,9 @@ @test cdf(poisson_constructor(1.0), 1) ≈ 2 * exp(-1.0) @test cdf(poisson_constructor(1.0), 100) ≈ 1.0 + @test invcdf(poisson_constructor(1.0), 0.0) ≈ 0 + @test invcdf(poisson_constructor(10.0), 0.5) ≈ 10 + @test KL_loss(poisson_constructor(1.0), poisson_constructor(1.0)) ≈ 0.0 @test KL_loss(poisson_constructor(1.0), poisson_constructor(2.0)) ≈ - log(2) + 1 @test KL_loss(poisson_constructor(2.0), poisson_constructor(1.0)) ≈ 2 * log(2) - 1