Skip to content

Estimate uncertainty of quantile/stats #59

Description

@athewsey

Currently, LLMeter provides point estimates of quantile stats (p90, p99, etc) and general warnings in the docs about the unreliability of extreme quantiles for small sample sizes.

Maybe we could consider providing more robust estimates of this uncertainty, to help guide when the quantiles aren't appropriate to use?

For example there's a proposed implementation here of confidence interval estimation for a quantile, and Claude suggested a similar approach as below:

from scipy.stats import binom

def quantile_ci(data, p, confidence=0.95):
    sorted_data = sorted(data)
    n = len(sorted_data)
    alpha = 1 - confidence
    # Find lower and upper order statistic indices
    lower = binom.ppf(alpha / 2, n, p)      # e.g. index of CI lower bound
    upper = binom.ppf(1 - alpha / 2, n, p)
    l, u = int(lower), int(min(upper, n - 1))
    if l == u:
        return None  # Can't form a CI — sample too small for this quantile
    return (sorted_data[l], sorted_data[u])

I'd need to spend longer staring at the stats to fully validate, but the general gist seems to be that there should be possibilities - with the main dependency being some kind of representation of the PMF/CDF of Binomial distribution... Which might be possible without taking on the heavy scipy library?

If we don't like the complexity of actually exposing the confidence intervals to users, then maybe it could just form the basis of an internal validity check that omits quantile stats we can't reliably estimate given the collected sample set?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions