Skip to content

Commit

Permalink
Test that the computed log-likelihood is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanaelbosch committed Feb 16, 2024
1 parent b9de4c0 commit 802f322
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/core/filtering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ProbNumDiffEq: IsometricKroneckerProduct, BlockDiag
import ProbNumDiffEq as PNDE
using BlockDiagonals
using FillArrays
import ProbNumDiffEq.GaussianDistributions: logpdf

@testset "PREDICT" begin
# Setup
Expand Down Expand Up @@ -140,6 +141,8 @@ end
_S = _SR'_SR
SM = Matrix(_S)

LL = logpdf(Gaussian(z, SM), z_data)

# UPDATE
KM = P_p_M * HM' / SM
m = m_p + KM * (z_data .- z)
Expand Down Expand Up @@ -198,7 +201,7 @@ end
z_cache = C_d
x_pred = Gaussian(x_pred.μ, PSDMatrix(P_p_R))
x_out = copy(x_pred)
ProbNumDiffEq.update!(
_, ll = ProbNumDiffEq.update!(
x_out,
x_pred,
msmnt,
Expand All @@ -211,6 +214,7 @@ end
)
@test m x_out.μ
@test P Matrix(x_out.Σ)
@test ll LL
end
@testset "Zero predicted covariance" begin
K_cache = copy(C_Dxd)
Expand Down Expand Up @@ -258,6 +262,8 @@ end
SR = qr([P_p_R * H'; R_R]).R |> Matrix
S = Symmetric(SR'SR)

LL = logpdf(Gaussian(z, S), z_data)

# UPDATE
S_inv = inv(S)
K = P_p * H' * S_inv
Expand Down Expand Up @@ -316,7 +322,7 @@ end
z_cache = C_d
x_pred = Gaussian(x_pred.μ, PSDMatrix(P_p_R))
x_out = copy(x_pred)
ProbNumDiffEq.update!(
_, ll = ProbNumDiffEq.update!(
x_out,
x_pred,
msmnt,
Expand All @@ -330,6 +336,7 @@ end
)
@test m x_out.μ
@test P Matrix(x_out.Σ)
@test ll LL
end
@testset "Zero predicted covariance" begin
K_cache = copy(C_Dxd)
Expand Down

0 comments on commit 802f322

Please sign in to comment.