Bug
ParticleDiagnostics.from_weights() normalizes nonnegative finite weights by summing them at their original scale. For valid inputs near the float64 limit, the sum can overflow to infinity even though all entries and their relative probabilities are well defined.
For example:
maximum = np.finfo(float).max
diagnostics = ParticleDiagnostics.from_weights([maximum, maximum / 2.0])
The current normalization computes an infinite total and therefore produces [0.0, 0.0]. The reported effective sample size and entropy are both zero instead of the correct values:
- normalized weights:
[2/3, 1/3]
- ESS:
1.8
- entropy: approximately
0.6365141683
Suggested fix
After validating finiteness, clip negative diagnostic weights as today, divide by the largest positive entry, and normalize the bounded scaled vector. Add a focused regression through ParticleDiagnostics.from_weights().
Bug
ParticleDiagnostics.from_weights()normalizes nonnegative finite weights by summing them at their original scale. For valid inputs near thefloat64limit, the sum can overflow to infinity even though all entries and their relative probabilities are well defined.For example:
The current normalization computes an infinite total and therefore produces
[0.0, 0.0]. The reported effective sample size and entropy are both zero instead of the correct values:[2/3, 1/3]1.80.6365141683Suggested fix
After validating finiteness, clip negative diagnostic weights as today, divide by the largest positive entry, and normalize the bounded scaled vector. Add a focused regression through
ParticleDiagnostics.from_weights().