Skip to content

Commit 5c5723e

Browse files
Add test
1 parent 87734ae commit 5c5723e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/container.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@
5151
)
5252
@test AdvancedPS.logZ(pc) log(sum(exp, 2 .* logps))
5353

54+
# Resample and propagate particles with reference particle
55+
particles_ref = [AdvancedPS.Trace(fpc(logp)) for logp in logps]
56+
pc_ref = AdvancedPS.ParticleContainer(particles_ref)
57+
AdvancedPS.resample_propagate!(
58+
Random.GLOBAL_RNG, pc_ref, AdvancedPS.resample_systematic, particles_ref[end]
59+
)
60+
@test pc_ref.logWs == zeros(3)
61+
@test AdvancedPS.getweights(pc_ref) == fill(1 / 3, 3)
62+
@test all(AdvancedPS.getweight(pc_ref, i) == 1 / 3 for i in 1:3)
63+
@test AdvancedPS.logZ(pc_ref) log(3)
64+
@test AdvancedPS.effectiveSampleSize(pc_ref) == 3
65+
@test pc_ref.vals[end] === particles_ref[end]
66+
5467
# Resample and propagate particles.
5568
AdvancedPS.resample_propagate!(Random.GLOBAL_RNG, pc)
5669
@test pc.logWs == zeros(3)

0 commit comments

Comments
 (0)