Skip to content

Commit

Permalink
Add tests comparing to base exp. fn.
Browse files Browse the repository at this point in the history
  • Loading branch information
smith-garrett committed Feb 20, 2023
1 parent a0d5266 commit a6e6a18
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/comp_base_exp.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@testset "Comparison to base exp()" begin
mat = [-1.0 1 0; 1 -2 1; 0 1 -1]
Q = TransitionRateMatrix(mat)
k = 2^12
tvals = [0.0, 1.0]
p0 = [1.0, 0, 0]
rt = 1e-4
for t in tvals
expQ = exp(mat * t)
pvec = expQ * p0
# Standard uniformization is not very accurate
@test all(isapprox.(standard_uniformization(Q, 2^14, t; p0=p0), pvec, atol=1e-2))

discobs = discrete_observation_times(Q, k, t)
@test all(isapprox.(discobs, expQ, rtol=rt))
@test all(isapprox.(discobs * p0, pvec, rtol=rt))

erl = erlangization(Q, k, t)
@test all(isapprox.(erl, expQ, rtol=rt))
@test all(isapprox.(erl * p0, pvec, rtol=rt))
end
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ using Uniformization
using Test

include("basic_tests.jl")
include("comp_base_exp.jl")

0 comments on commit a6e6a18

Please sign in to comment.