echo standardDeviation([5, 9, 4, 3, 2])."\n";
// Calculates standard deviation for the given integer array
function standardDeviation($a){
$count=count($a);
$v=0;
// Calculates average number from the array
$avg = array_sum($a) / $count;
// Loops through the array members
foreach ($a as $i){
// Calculates the sum of squares of the difference
// between each member and the average of the array
$v+=pow(($v-$avg), 2);
}
return sqrt($v/$count);
}