Skip to content

Commit 0fadd2b

Browse files
test
1 parent 29152da commit 0fadd2b

File tree

2 files changed

+4
-43
lines changed

2 files changed

+4
-43
lines changed

Diff for: src/algorithms/apf.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mutable struct AuxiliaryParticleFilter{RS<:AbstractConditionalResampler} <: Abst
77
end
88

99
function AuxiliaryParticleFilter(
10-
N::Integer; threshold::Real=1.0, resampler::AbstractResampler=Systematic()
10+
N::Integer; threshold::Real=0., resampler::AbstractResampler=Systematic()
1111
)
1212
conditional_resampler = ESSResampler(threshold, resampler)
1313
return AuxiliaryParticleFilter(N, conditional_resampler, zeros(N))

Diff for: test/runtests.jl

+3-42
Original file line numberDiff line numberDiff line change
@@ -95,53 +95,14 @@ end
9595
_, _, data = sample(rng, model, 20)
9696

9797
bf = BF(2^10; threshold=0.8)
98+
apf = APF(2^10, threshold=1.)
9899
_, llbf = GeneralisedFilters.filter(rng, model, bf, data)
100+
_, llapf= GeneralisedFilters.filter(rng, model, apf, data)
99101
_, llkf = GeneralisedFilters.filter(rng, model, KF(), data)
100102

101103
# since this is log valued, we can up the tolerance
102104
@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
145106
end
146107

147108
@testitem "Forward algorithm test" begin

0 commit comments

Comments
 (0)