Statistical Modes
Fair Forge metrics that perform statistical aggregation accept a pluggablestatistical_mode parameter. The same computation — estimating a rate, measuring distribution divergence, aggregating sub-metrics — can be performed either as a point estimate (Frequentist) or as a full posterior distribution with credible intervals (Bayesian).
Which Metrics Support Statistical Modes
| Metric | Primitives Used | What Gets a CI in Bayesian Mode |
|---|---|---|
| Toxicity | All four | DR, ASB, DTO, DIDT |
| Bias | rate_estimation | Bias rate per protected attribute |
| Agentic | rate_estimation | pass@K and pass^K |
The Four Primitives
StatisticalMode defines four abstract primitives. Every metric composes these to compute its final result — it never contains its own statistical logic.
rate_estimation(successes, trials)
Estimates a proportion from count data.
| Mode | Returns | How |
|---|---|---|
| Frequentist | float | successes / trials |
| Bayesian | dict with mean, ci_low, ci_high, samples | Beta-Binomial posterior: Beta(1 + successes, 1 + trials - successes) |
distribution_divergence(observed, reference)
Measures how far an observed distribution is from a reference.
| Mode | Returns | How | ||
|---|---|---|---|---|
| Frequentist | float | Total variation distance: `0.5 * Σ | p_i - q_i | ` |
| Bayesian | dict | Dirichlet posterior over p, divergence computed per MC sample |
aggregate_metrics(metrics, weights)
Combines multiple named sub-metrics into one weighted score.
| Mode | Returns | How |
|---|---|---|
| Frequentist | float | Normalized weighted sum |
| Bayesian | dict | Weighted sum applied per MC sample, then summarized |
dispersion_metric(values, center)
Measures how spread out a set of values is around their center.
| Mode | Returns | How |
|---|---|---|
| Frequentist | float | Mean absolute deviation (MAD) |
| Bayesian | dict | MAD computed per MC sample, then summarized |
Frequentist Mode
The default mode. Returns a single float for every primitive — no uncertainty, no samples.Usage
When to Use
- Large datasets (100+ samples) where point estimates are reliable
- Production systems where speed matters
- Quick exploratory analysis
Bayesian Mode
Returns full posterior distributions. Every primitive producesmean, ci_low, ci_high, and raw samples (MC draws). The CI width reflects how much uncertainty remains given the observed data.
BayesianMode Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
mc_samples | int | 5000 | Monte Carlo samples for posterior approximation |
ci_level | float | 0.95 | Credible interval level (e.g. 0.95 for 95% CI) |
dirichlet_prior | float | 1.0 | Symmetric Dirichlet prior for distribution_divergence |
beta_prior_a | float | 1.0 | Beta prior α for rate_estimation |
beta_prior_b | float | 1.0 | Beta prior β for rate_estimation |
rng_seed | int | None | 42 | Seed for reproducibility (None = random) |
Usage
When to Use
- Small datasets (fewer than 50–100 samples) where point estimates can be misleading
- Auditing and compliance contexts where uncertainty must be communicated
- Research applications requiring rigorous statistical reporting
- Any scenario where a wide CI should trigger a “collect more data” decision
How the CI Width Tells You When to Trust a Result
- Small Sample (n=10)
- Large Sample (n=200)
- Agentic pass@K
With 10 interactions and 3 flagged as biased:
- Frequentist: bias rate = 0.30 (single number, no context)
- Bayesian: bias rate = 0.30 CI = [0.09, 0.57]
Priors in Bayesian Mode
Beta Prior (for rate_estimation)
Used in Bias (bias rate) and Agentic (success rate). The Beta(a, b) prior expresses beliefs before seeing any data.
Dirichlet Prior (for distribution_divergence)
Used in Toxicity (DR — demographic representation). The dirichlet_prior scalar sets concentration across all categories.
Custom Statistical Modes
ImplementStatisticalMode to plug in your own strategy (e.g., Wilson score intervals, KL divergence):
Next Steps
Toxicity Metric
Statistical modes with group profiling (DR, DTO, ASB, DIDT)
Bias Metric
Beta-Binomial posteriors for protected attribute bias rates
Agentic Metric
Credible intervals for pass@K and pass^K