FUNCTION
Avedev
Calculates the absolute deviation of a given set of data.
Interface
#include <codecogs/statistics/moments/avedev.h>
using namespace Statistics::Moments;
The absolute deviation of an element of a data set is the absolute difference between that element and a given point. Typically the point from which the deviation is measured is the value of either the median or the mean of the data set.
The average absolute deviation of a data set is the average of the absolute deviations and is a summary statistic of statistical dispersion or variability.
The average absolute deviation of a set is:
where is the selected value of central tendency of the set about which the average absolute deviation is being measured. In general, the average absolute deviation from the mean is between one and two times the average absolute deviation from the median; it is also less than or equal to the standard deviation.
References
Wikipedia, http://en.wikipedia.org/wiki/Absolute_deviation
Example 1
#include <codecogs/statistics/moments/avedev.h>
#include <iostream>
int main()
{
double x[5] = {3.4 , 7.5 , 8.5 , 0.6 , 3.9};
double adev = Stats::Moments::avedev<double>(5, x);
std::cout << "The absolute deviation is: " << adev << std::endl;
return 0;
}Output:
The absolute deviation is:2.576