Calculates the absolute deviation of a given set of data.

View versions (1)

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 {x_1, x_2 ..., x_N} is:

avedev=\frac{\sum_{i=1}^N|x_i-\overline{x}|}{N}
(1)

where \overline{x} 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

Parameters

n
the size of the population
data
the actual population data given asa an array

Returns

return value the absolute deviation of the given set of data
GPL Licence — free for non commercial use. See Licence details.