Skip to content

Commit 2138418

Browse files
committed
Add more standard measure logdensityof tests
1 parent 1b434a7 commit 2138418

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/test_standard.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,25 @@ using Distributions: Normal, Exponential, Logistic, Uniform
2626
end
2727
end
2828
end
29+
30+
using LogExpFunctions: log1pexp
31+
using IrrationalConstants: log2π
32+
33+
@testset "Standard measure logdensityof" begin
34+
# StdNormal
35+
@test logdensityof(StdNormal(), 0.0) -log2π / 2
36+
@test logdensityof(StdNormal(), 1.0) (-1 - log2π) / 2
37+
38+
# StdUniform
39+
@test logdensityof(StdUniform(), 0.5) == 0.0
40+
@test logdensityof(StdUniform(), 1.5) == -Inf
41+
@test logdensityof(StdUniform(), -0.5) == -Inf
42+
43+
# StdLogistic
44+
x = 1.0
45+
@test logdensityof(StdLogistic(), x) -abs(x) - 2 * log1pexp(-abs(x))
46+
47+
# StdExponential
48+
@test logdensityof(StdExponential(), 1.0) -1.0
49+
@test logdensityof(StdExponential(), -1.0) == -Inf
50+
end

0 commit comments

Comments
 (0)