This kind of sidesteps the issue (and you should address it), but sq_square
is small enough you may want to consider simply inlining
Change:
return sqrt(array_sum(array_map("sd_square", $array, array_fill(0,count($array), (array_sum($array) / count($array)) ) ) ) / (count($array)) );
To:
return sqrt(array_sum(array_map(function ($x, $mean) { return pow($x - $mean,2); }, $array, array_fill(0,count($array), (array_sum($array) / count($array)) ) ) ) / (count($array)) );
Or:
$sd_square = function ($x, $mean) { return pow($x - $mean,2); };
return sqrt(array_sum(array_map($sd_square, $array, array_fill(0,count($array), (array_sum($array) / count($array)) ) ) ) / (count($array)) );