hfppl icon indicating copy to clipboard operation
hfppl copied to clipboard

Add stratified resampling; improve handling of -inf weights

Open benlebrun opened this issue 8 months ago • 1 comments

This PR adds stratified resampling to smc_standard. The resampling method can be specified by a new resampling_method argument to smc_standard which defaults to multinomial (and thus preserves the past behaviour).

I have also improved the handling of cases in which all particles have -inf weight. Previously our logsumexp method would return nan and raised a warning. I've added a case to logsumexp which returns -inf when all input weights are -inf. We also skip the resampling step (and ess_threshold check) when all particles are -inf.

benlebrun avatar Apr 16 '25 15:04 benlebrun

Codecov Report

Attention: Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
llamppl/inference/smc_standard.py 88.46% 3 Missing :warning:
llamppl/util.py 66.66% 1 Missing :warning:

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar Apr 16 '25 16:04 codecov[bot]