Skip to content

goodhistogram: add regression test for rightmost-bucket density fix - #13

Merged
angles-n-daemons merged 1 commit into
mainfrom
bdillmann/quantile-boundary-density-test
Aug 26, 2026
Merged

angles-n-daemons merged 1 commit into
mainfrom
bdillmann/quantile-boundary-density-test

Conversation

@angles-n-daemons

Copy link
Copy Markdown
Contributor

Summary

The rightmost-bucket density bias fixed in f4b1ed8 ("fix rightmost-bucket density bias in quantile interpolation") shipped without a regression test. This adds one.

TestQuantileTopBucketDensity places all mass in the last in-range bucket and asserts the median lands at or past the bucket midpoint:

  • With the fix (right-edge density = last bucket's own average), the density rises across the top bucket, so the median sits at/past the midpoint.
  • Under the bug (right-edge density left at 0), the top bucket is modeled as a downslope to zero, pulling the median below the midpoint.

It covers both the single-value (ValueAtQuantile) and batch (ValuesAtQuantiles) paths, since they compute boundary densities independently.

Verification

  • Fails when boundaryDensity[n] is reset to 0 (median 972810 < midpoint 980774).
  • Passes against current main.

No production code changes.

The rightmost-bucket density bias fixed in f4b1ed8 shipped without a
regression test. Add TestQuantileTopBucketDensity, which places all mass
in the last in-range bucket and asserts the median lands at or past the
bucket midpoint. With the fix (right-edge density = last bucket's average)
the density rises across the bucket and the median sits past the midpoint;
under the bug (right-edge density = 0) it is pulled below. The test covers
both the single-value (ValueAtQuantile) and batch (ValuesAtQuantiles)
paths, which compute boundary densities independently.

Verified the test fails when boundaryDensity[n] is reset to 0 and passes
against the current code.

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@angles-n-daemons
angles-n-daemons merged commit 7114f09 into main Aug 26, 2026
3 checks passed
@angles-n-daemons
angles-n-daemons deleted the bdillmann/quantile-boundary-density-test branch August 26, 2026 17:46
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