-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce resampler that checks if resampling required #563
Conversation
1f1eb18
to
83dbdb2
Compare
Codecov Report
@@ Coverage Diff @@
## main #563 +/- ##
=======================================
Coverage 94.24% 94.25%
=======================================
Files 144 144
Lines 7121 7133 +12
Branches 1341 1345 +4
=======================================
+ Hits 6711 6723 +12
Misses 310 310
Partials 100 100
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
stonesoup/resampler/particle.py
Outdated
class ESSResampler(SystematicResampler): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could do with a docstring, to explain a little about what it does, and any references you've used.
stonesoup/resampler/particle.py
Outdated
parent=Particles(state_vector=particles.state_vector[:, index], | ||
weight=particles.weight[index])) | ||
return new_particles | ||
|
||
|
||
class ESSResampler(SystematicResampler): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this class could be a wrapper that could be used with other resamplers.
class ESSResampler(Resampler):
resampler: Resampler = Property(doc="Resampler to wrap, which is called when ESS below threshold")
...
stonesoup/resampler/particle.py
Outdated
class ESSResampler(SystematicResampler): | ||
|
||
threshold: float = Property(default=None, | ||
doc='Threshold compared with ESS to decide whether to resample') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to add to doc that default of None
means threshold is number of particles / 2.
3cbdb4a
to
aaa2c92
Compare
This change is in response to #495
The new ESSResampler class checks whether the ESS (Effective Sample Size) is below a given threshold before proceeding, otherwise simply returning the original particles without any resampling.