|
95 | 95 | _, _, data = sample(rng, model, 20)
|
96 | 96 |
|
97 | 97 | bf = BF(2^10; threshold=0.8)
|
| 98 | + apf = APF(2^10, threshold=1.) |
98 | 99 | _, llbf = GeneralisedFilters.filter(rng, model, bf, data)
|
| 100 | + _, llapf= GeneralisedFilters.filter(rng, model, apf, data) |
99 | 101 | _, llkf = GeneralisedFilters.filter(rng, model, KF(), data)
|
100 | 102 |
|
101 | 103 | # since this is log valued, we can up the tolerance
|
102 | 104 | @test llkf ≈ llbf atol = 2
|
103 |
| -end |
104 |
| - |
105 |
| -@testitem "APF filter test" begin |
106 |
| - using GeneralisedFilters |
107 |
| - using SSMProblems |
108 |
| - using StableRNGs |
109 |
| - using PDMats |
110 |
| - using LinearAlgebra |
111 |
| - using Random: randexp |
112 |
| - |
113 |
| - T = Float32 |
114 |
| - rng = StableRNG(1234) |
115 |
| - σx², σy² = randexp(rng, T, 2) |
116 |
| - |
117 |
| - # initial state distribution |
118 |
| - μ0 = zeros(T, 2) |
119 |
| - Σ0 = PDMat(T[1 0; 0 1]) |
120 |
| - |
121 |
| - # state transition equation |
122 |
| - A = T[1 1; 0 1] |
123 |
| - b = T[0; 0] |
124 |
| - Q = PDiagMat([σx²; 0]) |
125 |
| - |
126 |
| - # observation equation |
127 |
| - H = T[1 0] |
128 |
| - c = T[0;] |
129 |
| - R = [σy²;;] |
130 |
| - |
131 |
| - # when working with PDMats, the Kalman filter doesn't play nicely without this |
132 |
| - function Base.convert(::Type{PDMat{T,MT}}, mat::MT) where {MT<:AbstractMatrix,T<:Real} |
133 |
| - return PDMat(Symmetric(mat)) |
134 |
| - end |
135 |
| - |
136 |
| - model = create_homogeneous_linear_gaussian_model(μ0, Σ0, A, b, Q, H, c, R) |
137 |
| - _, _, data = sample(rng, model, 20) |
138 |
| - |
139 |
| - bf = APF(2^10, threshold=0.8) |
140 |
| - _, llbf = GeneralisedFilters.filter(rng, model, bf, data) |
141 |
| - _, llkf = GeneralisedFilters.filter(rng, model, KF(), data) |
142 |
| - |
143 |
| - # since this is log valued, we can up the tolerance |
144 |
| - @test llkf ≈ llbf atol = 2 |
| 105 | + @test llkf ≈ llapf atol = 2 |
145 | 106 | end
|
146 | 107 |
|
147 | 108 | @testitem "Forward algorithm test" begin
|
|
0 commit comments