PHP : Function Reference : Statistics Functions : stats_standard_deviation
kotecky o hotmail o com
mightymrj
Here's a couple functions I made that easily calculate the standard deviation.
function average($array){
$sum = array_sum($array);
$count = count($array);
return $sum/$count;
}
//The average function can be use independantly but the deviation function uses the average function.
function deviation ($array){
$avg = average($array);
foreach ($array as $value) {
$variance[] = pow($value-$avg, 2);
}
$deviation = sqrt(average($variance));
return $deviation;
}
I hope this is useful
|