/** * Make the z-transform of averages of the cities * @param array $munAverages * @return Return a array with the z value of each city */ public function zTransformation($munAverages) { //make average of given cities' averages $sumAvg = 0; $avg = 0; foreach ($munAverages as $key => $value) { $sumAvg += $value; } $avg = $sumAvg / sizeof($munAverages); //Calculate Standard Deviation $std = ZtransformController::standarDeviation($munAverages, $avg); //Apply the z-transform and save the results in an array $zValues = array(); //keep the z-transform results $zTransform = 0; foreach ($munAverages as $key => $value) { $zTransform = ($value - $avg) / $std; $zValues = array_merge($zValues, array($key => $zTransform)); } return $zValues; }