From 30d7df2b3ea55c770ec55c6170f26c41a97a334a Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Mon, 6 Jan 2025 22:39:21 +0530 Subject: [PATCH] chore: separate variance and deviation, penta stuff --- arbiter/src/eve/stats.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/arbiter/src/eve/stats.rs b/arbiter/src/eve/stats.rs index 19b9747..765349e 100644 --- a/arbiter/src/eve/stats.rs +++ b/arbiter/src/eve/stats.rs @@ -116,7 +116,9 @@ impl Model { /// sample data. fn mean(&self, x: Score) -> f64 { match *self { - Self::Pentanomial => 0.0, + Self::Pentanomial => { + 0.00 * x.ll + 0.25 * x.ld + 0.50 * (x.dd + x.wl) + 0.75 * x.wd + 1.00 * x.ww + } Self::Traditional => 1.0 * x.w + 0.5 * x.d + 0.0 * x.l, } } @@ -124,14 +126,25 @@ impl Model { /// Calculates the deviation (square root of the variance) of the given /// sample data from the given pivot point. fn deviation(&self, x: Score, mu: f64) -> f64 { + self.variance(x, mu).sqrt() + } + + /// Calculates the variance of the given sample data from the given pivot. + fn variance(&self, x: Score, mu: f64) -> f64 { match *self { - Self::Pentanomial => 0.0, + Self::Pentanomial => { + ((x.dd + x.wl) * f64::powi(0.50 - mu, 2) + + x.ll * f64::powi(0.00 - mu, 2) + + x.ld * f64::powi(0.25 - mu, 2) + + x.wd * f64::powi(0.75 - mu, 2) + + x.ww * f64::powi(1.00 - mu, 2)) + / x.n + } Self::Traditional => { - f64::sqrt( - 0.0 + x.w * f64::powi(1.0 - mu, 2) - + x.d * f64::powi(0.5 - mu, 2) - + x.l * f64::powi(0.0 - mu, 2), - ) / f64::sqrt(x.n * 2.0) + (x.w * f64::powi(1.0 - mu, 2) + + x.d * f64::powi(0.5 - mu, 2) + + x.l * f64::powi(0.0 - mu, 2)) + / (x.n * 2.0) } } }