confi
Confi
confi provides lightweight, type-safe primitives for expressing
statistical confidence levels, significance levels, and confidence intervals.
The crate is designed to make statistical intent explicit in code, without pulling in heavy statistical frameworks.
It focuses on representation and validation, not on distribution modeling.
Core types
- [
ConfidenceLevel] — probability that a procedure correctly captures the true value - [
SignificanceLevel] — probability threshold for hypothesis testing (α) - [
ConfidenceInterval] — bounded estimate with an associated confidence level
All types enforce that probabilities remain in the valid range [0, 1].
Key concepts
Confidence vs significance
Confidence and significance are duals:
confidence = 1 - significance
use ;
let c = from_percent?;
let a: = c.significance;
assert_relative_eq!;
Confidence intervals
A confidence interval combines:
- a lower bound
- an upper bound
- a confidence level
use ;
let level = from_percent?;
let ci = new?;
assert!;
Intervals are closed: lower ≤ x ≤ upper.
Features
Safe probability types
All probability-like values are validated to ensure:
0 ≤ p ≤ 1- no NaN values
- finite values only
Design philosophy
This crate is intentionally minimal:
- No statistical distributions are included
- No hypothesis testing logic is implemented
- No external statistical dependencies are required
It is intended as a building block library for statistical systems, not a full statistics toolkit.
Example
use ;
let confidence = from_percent?;
let alpha: = confidence.into;
let ci = new?;
assert!;
assert_relative_eq!;
License: MIT