Skip to content

Commit

Permalink
chore: separate variance and deviation, penta stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
raklaptudirm committed Jan 6, 2025
1 parent 17c3245 commit 30d7df2
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions arbiter/src/eve/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,35 @@ 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,
}
}

/// 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)
}
}
}
Expand Down

0 comments on commit 30d7df2

Please sign in to comment.