Skip to content

BUG: accumulate float32 nanmean in float64 - #634

Open
AryanRG wants to merge 1 commit into
pydata:masterfrom
AryanRG:fix/float32-nanmean-accuracy
Open

AryanRG wants to merge 1 commit into
pydata:masterfrom
AryanRG:fix/float32-nanmean-accuracy

Conversation

@AryanRG

@AryanRG AryanRG commented Dec 1, 2026

Copy link
Copy Markdown

On the 50-million-element float32 example from #462, bn.nanmean gives 0.33554432 for data with a mean near 0.5. The running sum loses contributions once its spacing grows too large.

Accumulate native float32 inputs in float64 and round the mean once, after division. This applies to full-array and axis reductions and preserves their existing return types. With a fixed seed, both now give 0.50000060, the float32-rounded reference. This addresses the mean reported in #462. The standard deviation has a separate fix in #608.

Both regression cases failed on master. The full suite on macOS arm64 passed with 210 tests and one expected failure.

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