reach.uncertainty¶
Statistical uncertainty estimation, Wilson score confidence intervals, and power analysis.
Calculate statistical confidence intervals and power for rate metrics.
Interval ¶
Bases: BaseModel
Represent a statistical confidence interval with lower and upper bounds.
Source code in src/reach/uncertainty.py
excludes ¶
format_percent ¶
Format the interval as a percentage range string '[low% - high%]'.
from_tuple
classmethod
¶
from_tuple(
bounds: Interval | Sequence[float],
confidence: float = DEFAULT_CONFIDENCE,
) -> Self
Construct an Interval from an existing Interval or a 2-element sequence.
Source code in src/reach/uncertainty.py
unit
classmethod
¶
zero
classmethod
¶
cluster_wilson_interval ¶
cluster_wilson_interval(
hits: int,
probes: int,
attempts: int = 1,
confidence: float = DEFAULT_CONFIDENCE,
intra_cluster_correlation: float = 0.6,
*,
queries_per_skill: float = 1.0,
skill_icc: float = 0.0,
) -> Interval | None
Calculate Wilson score confidence interval adjusted for cluster design effect.
Source code in src/reach/uncertainty.py
detectable_delta ¶
detectable_delta(
probes: int,
confidence: float = DEFAULT_CONFIDENCE,
power: float = DEFAULT_POWER,
) -> float | None
Calculate the minimum detectable rate delta for a given sample size per arm.
Source code in src/reach/uncertainty.py
effective_sample_size ¶
effective_sample_size(
sample_size: int,
attempts: int = 1,
intra_cluster_correlation: float = 0.6,
*,
queries_per_skill: float = 1.0,
skill_icc: float = 0.0,
) -> int
Calculate survey-style effective sample size adjusting for cluster correlation.
Source code in src/reach/uncertainty.py
estimate_skill_icc ¶
Estimate intra-skill correlation via one-way random-effects ANOVA across skills.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outcomes_by_skill
|
Mapping[str, Sequence[float]]
|
Mapping of skill names to sequences of per-query pass rates. |
required |
Returns:
| Type | Description |
|---|---|
float | None
|
Estimated intra-class correlation coefficient in [0.0, 1.0], or None when |
float | None
|
fewer than two skills or zero within-skill degrees of freedom are available. |
Source code in src/reach/uncertainty.py
required_probes ¶
required_probes(
delta: float,
confidence: float = DEFAULT_CONFIDENCE,
power: float = DEFAULT_POWER,
) -> int
Calculate sample size per arm required to detect a rate delta with power.