/** * Calculates the standard deviation of the specified elements. If the given * elements is a population then the population standard deviation is * calculated otherwise the sample standard deviation. * * @param array $elements list of element from a sample or population * distribution. * @param boolean $population true if the element list is a population * distribution. * * @return the variance of the specified elements. */ public static function stdv($elements, $population = FALSE) { $stdv = 0.0; $variance = 0.0; $n = count($elements); $mean = Math::mean($elements); $variance = Math::variance($elements, $population); $stdv = pow($variance, 0.5); // $stdv = sqrt($variance); return $stdv; }