Skip to content

feat: add quantile confidence intervals and reliability gating#85

Open
acere wants to merge 1 commit into
awslabs:mainfrom
acere:feat/quantile-ci
Open

feat: add quantile confidence intervals and reliability gating#85
acere wants to merge 1 commit into
awslabs:mainfrom
acere:feat/quantile-ci

Conversation

@acere

@acere acere commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds confidence interval estimation for quantile statistics using the exact binomial method, addressing #59.

When enabled via the confidence parameter on summary_stats_from_list, unreliable quantiles (where sample size is too small to form a meaningful CI) are omitted from output, and CI bounds are attached to reliable ones.

Changes

  • New module llmeter/quantile_ci.py — pure-Python implementation using math.lgamma (zero external deps)
    • quantile_ci(data, quantile, confidence)(lower, upper) or None
    • can_estimate_quantile(n, quantile, confidence) → boolean gate
  • Extended summary_stats_from_list with opt-in confidence: float | None parameter (backward-compatible)
  • Added RunningStats.snapshot() for live progress display
  • Documentation — user guide page and API reference, wired into mkdocs nav

Minimum sample sizes (95% confidence)

Quantile Min samples
p50 8
p90 46
p99 482

Testing

  • tests/test_quantile_ci.py — unit tests for binomial internals and public API
  • tests/test_utils_ci_gating.py — integration tests for gated behavior in summary_stats_from_list
  • All 896 unit tests pass

Closes #59

…bs#59)

Add confidence interval estimation for quantile statistics using the
exact binomial method (zero external dependencies). When enabled via
`confidence` parameter on `summary_stats_from_list`, unreliable quantiles
are omitted and CI bounds are attached to reliable ones.

Changes:
- New module `llmeter/quantile_ci.py` with `quantile_ci()` and
  `can_estimate_quantile()` functions
- Extended `summary_stats_from_list` with opt-in `confidence` parameter
- Added `RunningStats.snapshot()` for live progress display
- Added user guide and API reference documentation
- Wired new docs pages into mkdocs.yml nav

Closes awslabs#59
@acere
acere requested a review from athewsey June 16, 2026 12:18
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.

Estimate uncertainty of quantile/stats

1 participant