Skip to content

Accept integer weights in weighted quantiles - #348

Open
antonsoo wants to merge 1 commit into
dfm:mainfrom
antonsoo:fix/integer-quantile-weights
Open

antonsoo wants to merge 1 commit into
dfm:mainfrom
antonsoo:fix/integer-quantile-weights

Conversation

@antonsoo

Copy link
Copy Markdown

Integer sample weights currently make weighted quantiles fail during CDF normalization:

import corner

print(corner.quantile([0., 1., 2.], [0.5], weights=[1, 1, 1]))
# Before: UFuncTypeError when dividing the integer CDF in place
# After: [1.0]

Accumulate the CDF with a dtype promoted to at least float64. This accepts integer lists/arrays and avoids integer accumulation overflow while preserving extended floating precision. The existing quantile convention is unchanged.

Regression tests cover integer lists, signed arrays and unsigned arrays. The complete suite passes on Python 3.12 and 3.14, with the existing skip, and all pre-commit hooks pass. On archived eight-schools posterior draws, integer-weight plots, titles and percentile ranges match the corresponding floating-weight results, including rendered images.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant