Add stratified resampling; improve handling of -inf weights
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.
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!