16 lines
980 B
Rust
16 lines
980 B
Rust
/// Confidence floor of an ABSTAIN caused by uncertainty (right at the edge).
|
|
pub const MIN_UNCERTAIN_CONFIDENCE: f64 = 0.05;
|
|
/// Ceiling (at the rim of the band). An uncertainty ABSTAIN never exceeds this.
|
|
pub const MAX_UNCERTAIN_CONFIDENCE: f64 = 0.30;
|
|
|
|
/// Confidence of an uncertainty ABSTAIN: `0.05 + 0.25 * distance / width`, where
|
|
/// `distance` is how far the evidence is from the edge being decided (break-even,
|
|
/// or the EV tie) and `width` the uncertainty band. On the edge the engine is least
|
|
/// sure (0.05); at the rim of the band it is most sure (0.30). Total: NaN, negative or
|
|
/// zero-width input gives the floor or the ceiling, never anything outside the range.
|
|
pub fn abstain_confidence(distance: f64, width: f64) -> f64 {
|
|
let ratio = if width > 0.0 { (distance / width).clamp(0.0, 1.0) } else { 1.0 };
|
|
let ratio = if ratio.is_nan() { 0.0 } else { ratio };
|
|
MIN_UNCERTAIN_CONFIDENCE + (MAX_UNCERTAIN_CONFIDENCE - MIN_UNCERTAIN_CONFIDENCE) * ratio
|
|
}
|