This commit is contained in:
Andrea Cavalli 2019-12-02 12:59:54 +01:00
parent c1a0fd14ff
commit e4ed6fd1b8
2 changed files with 4 additions and 4 deletions

View File

@ -83,7 +83,7 @@ impl Variance0 {
/// This is an unbiased estimator of the variance of the population.
#[inline]
pub fn sample_variance(&self) -> f64 {
if self.avg.len() < 1 + ddof {
if self.avg.len() < 1 + ddof as usize {
return 0.;
}
self.sum_2 / f64::approx_from(self.avg.len() - ddof).unwrap()
@ -95,7 +95,7 @@ impl Variance0 {
#[inline]
pub fn population_variance(&self) -> f64 {
let n = self.avg.len();
if n < 1 + ddof {
if n < 1 + ddof as usize {
return 0.;
}
self.sum_2 / f64::approx_from(n).unwrap()

View File

@ -83,7 +83,7 @@ impl Variance1 {
/// This is an unbiased estimator of the variance of the population.
#[inline]
pub fn sample_variance(&self) -> f64 {
if self.avg.len() < 1 + ddof {
if self.avg.len() < 1 + ddof as usize {
return 0.;
}
self.sum_2 / f64::approx_from(self.avg.len() - ddof).unwrap()
@ -95,7 +95,7 @@ impl Variance1 {
#[inline]
pub fn population_variance(&self) -> f64 {
let n = self.avg.len();
if n < 1 + ddof {
if n < 1 + ddof as usize {
return 0.;
}
self.sum_2 / f64::approx_from(n).unwrap()