com.quantarray.anaheim.numerics.Variance.scala Maven / Gradle / Ivy
package com.quantarray.anaheim.numerics
object Variance {
/**
* Computes variance of the entire population.
*/
def forPopulationOf(xs: Seq[Double]): Double = {
val mean = Mean.of(xs)
xs.map(x => (x - mean) * (x - mean)).sum / xs.size
}
}