← Lab
residbias
confirmedupstream bugPython · filterpySystems & data structuresJuly 25, 2026
the question
Is filterpy's residual_resample unbiased with E[count_i] equal to N*w_i?
what came out
filterpy's residual_resample computes the fractional residual as weights - floor(N*w) instead of N*w - floor(N*w), dropping the factor N. Residuals of above-average particles go negative, so the heavy particle is over-replicated (2.748 vs 2.0) and light particles starve to zero copies. The sibling systematic_resample is unbiased.
method & receipts
- Result: confirmed
- Reproducible — one script re-runs the whole thing from scratch.
- Tested — a correctness/benchmark suite ships alongside the code.
→ read the code and re-run it
github.com/v-code01/residbias