Skip to content

Commit 5df4844

Browse files
committed
Add test for support of OrderedLogistic
We add the test that the support should have the right number of elements, and that the probabilities add up to 1.0.
1 parent 95e552d commit 5df4844

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/stdlib/distributions.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ using Turing
3232
@test all(((x, y),) -> abs(x - y) < 0.001, zip(p, pmf))
3333
end
3434

35+
@testset "distribution functions" begin
36+
d = OrderedLogistic(0, [1, 2, 3])
37+
38+
K = length(d.cutpoints) + 1
39+
@test support(d) == 1:K
40+
41+
# Adding up probabilities sums to 1
42+
s = sum(pdf.(d, support(d)))
43+
@test s 1.0 atol = 0.0001
44+
end
45+
46+
3547
@testset "distributions functions" begin
3648
λ = 0.01:0.01:5
3749
LLp = @. logpdf(Poisson(λ), 1)

0 commit comments

Comments
 (0)