Skip to content

Commit 87734ae

Browse files
Propagate ref particle in PG
1 parent 176640e commit 87734ae

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/container.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,16 @@ The resampling steps use the given `resampler`.
314314
Del Moral, P., Doucet, A., & Jasra, A. (2006). Sequential monte carlo samplers.
315315
Journal of the Royal Statistical Society: Series B (Statistical Methodology), 68(3), 411-436.
316316
"""
317-
function sweep!(rng::Random.AbstractRNG, pc::ParticleContainer, resampler)
317+
function sweep!(
318+
rng::Random.AbstractRNG,
319+
pc::ParticleContainer,
320+
resampler,
321+
ref::Union{Particle,Nothing}=nothing,
322+
)
318323
# Initial step:
319324

320325
# Resample and propagate particles.
321-
resample_propagate!(rng, pc, resampler)
326+
resample_propagate!(rng, pc, resampler, ref)
322327

323328
# Compute the current normalizing constant ``Z₀`` of the unnormalized logarithmic
324329
# weights.
@@ -339,7 +344,7 @@ function sweep!(rng::Random.AbstractRNG, pc::ParticleContainer, resampler)
339344
# For observations ``y₂, …, yₜ``:
340345
while !isdone
341346
# Resample and propagate particles.
342-
resample_propagate!(rng, pc, resampler)
347+
resample_propagate!(rng, pc, resampler, ref)
343348

344349
# Compute the current normalizing constant ``Z₀`` of the unnormalized logarithmic
345350
# weights.

src/smc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function AbstractMCMC.step(
114114
particles = ParticleContainer(x)
115115

116116
# Perform a particle sweep.
117-
logevidence = sweep!(rng, particles, sampler.resampler)
117+
logevidence = sweep!(rng, particles, sampler.resampler, particles.vals[nparticles])
118118

119119
# Pick a particle to be retained.
120120
newtrajectory = rand(rng, particles)

0 commit comments

Comments
 (0)