Add midpoint-based mean to CumulativeRO histogram#19
Merged
Conversation
Compute the mean of all observations using bucket midpoints once at construction time and store it on the CumulativeROHistogram(32) struct, exposed via a mean() accessor. Eq can no longer be derived since the field is an f64, so it is dropped (PartialEq is retained). https://claude.ai/code/session_018jnFHZj1HLmmL98TR2JwcF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
meanfield toCumulativeROHistogram/CumulativeROHistogram32, holding the mean of all observations estimated from bucket midpoints.from_parts,From<&Histogram>, andFrom<&SparseHistogram>.mean() -> Option<f64>accessor (Nonefor an empty histogram).Details
Σ(midpoint_i · individual_count_i) / total_count, wheremidpoint_i = (range.start + range.end) / 2for each non-zero bucket.Eqcan no longer be derived for the owned struct because it now stores anf64;PartialEqis retained. The borrowed*Refview types are unchanged (they don't store the mean).1.4.0-alpha.0per the repo's feature-PR versioning policy.Test plan
cargo test(115 + 5 tests pass)cargo build --all-featuresandcargo clippy --all-featurescleanfrom_partsvalue, midpoint usage, empty ->None, parity across constructors vs. independent iterator computation, u32 varianthttps://claude.ai/code/session_018jnFHZj1HLmmL98TR2JwcF
Generated by Claude Code