To calculate average, I was able to coding. here suppose there are a number of figures.
A
======
6
3
3
4
======
We know the Average formula is : 1/n*sigma(Ai) so i define in code like:
function calculate_average($arr) {
$count = count($arr);
foreach ($arr as $value) {
$total = $total + $value;
}
$average = ($total/$count);
return $average;
}
$home_values_array = array("6", "3", "3","4");
$average_home_value = calculate_average($home_values_array);
echo 'Average home value: $'.number_format($average_home_value).'</p>';
My next task is calc mean deviation, here is the formula :
A B
==========
6 8
3 7
3 6
4 5
==========
Mean Dev = 1/n*sigma(|Ai-Bi|)
My question is how to develop my average code to coding the mean dev calculate, or just simply, how to solve the mean dev code.
Big thanks for the help.
I don't know it's what you need or not.
Check this link too see how code run. Hope this helps