Skip to content

Commit

Permalink
add tests poisson
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvanerp committed Aug 27, 2024
1 parent 49162d6 commit aaf62bf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/distributions/poisson_tests.jl
Original file line number Diff line number Diff line change
@@ -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(λ)])

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit aaf62bf

Please sign in to comment.