| 385 | } |
| 386 | |
| 387 | fn evaluate(&mut self) -> Result<ScalarValue> { |
| 388 | let count = match self.stats_type { |
| 389 | StatsType::Population => self.count, |
| 390 | StatsType::Sample => { |
| 391 | if self.count > 0 { |
| 392 | self.count - 1 |
| 393 | } else { |
| 394 | self.count |
| 395 | } |
| 396 | } |
| 397 | }; |
| 398 | |
| 399 | Ok(ScalarValue::Float64(match self.count { |
| 400 | 0 => None, |
| 401 | 1 => { |
| 402 | if let StatsType::Population = self.stats_type { |
| 403 | Some(0.0) |
| 404 | } else { |
| 405 | None |
| 406 | } |
| 407 | } |
| 408 | _ => Some(self.m2 / count as f64), |
| 409 | })) |
| 410 | } |
| 411 | |
| 412 | fn size(&self) -> usize { |
| 413 | size_of_val(self) |