I am trying to calculate Z-scores using PHP. Essentially, I am looking for the most efficient way to calculate the mean and standard deviation of a data set (PHP array). Any
function standard_deviation($aValues) { $fMean = array_sum($aValues) / count($aValues); //print_r($fMean); $fVariance = 0.0; foreach ($aValues as $i) { $fVariance += pow($i - $fMean, 2); } $size = count($aValues) - 1; return (float) sqrt($fVariance)/sqrt($size); }