Skip to content

Add midpoint-based mean to CumulativeRO histogram#19

Merged
thinkingfish merged 2 commits into
mainfrom
claude/add-histogram-mean-value-pqtTz
May 19, 2026
Merged

Add midpoint-based mean to CumulativeRO histogram#19
thinkingfish merged 2 commits into
mainfrom
claude/add-histogram-mean-value-pqtTz

Conversation

@thinkingfish

Copy link
Copy Markdown
Member

Summary

  • Add a mean field to CumulativeROHistogram / CumulativeROHistogram32, holding the mean of all observations estimated from bucket midpoints.
  • Compute it once at construction time across all three entry points: from_parts, From<&Histogram>, and From<&SparseHistogram>.
  • Expose it via a mean() -> Option<f64> accessor (None for an empty histogram).

Details

  • Mean is computed as Σ(midpoint_i · individual_count_i) / total_count, where midpoint_i = (range.start + range.end) / 2 for each non-zero bucket.
  • Eq can no longer be derived for the owned struct because it now stores an f64; PartialEq is retained. The borrowed *Ref view types are unchanged (they don't store the mean).
  • Version bumped to 1.4.0-alpha.0 per the repo's feature-PR versioning policy.

Test plan

  • cargo test (115 + 5 tests pass)
  • cargo build --all-features and cargo clippy --all-features clean
  • New tests: from_parts value, midpoint usage, empty -> None, parity across constructors vs. independent iterator computation, u32 variant

https://claude.ai/code/session_018jnFHZj1HLmmL98TR2JwcF


Generated by Claude Code

claude added 2 commits May 19, 2026 16:53
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
@thinkingfish thinkingfish marked this pull request as ready for review May 19, 2026 17:01
@thinkingfish thinkingfish merged commit f4858d0 into main May 19, 2026
6 checks passed
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.

2 participants