Calculates the sum of squared deviations of a given set of data.

View versions (1)

Interface

#include <codecogs/statistics/moments/squared_deviations.h>

using namespace Statistics::Moments;

Returns the sum of squares of deviations of data points from their sample mean. The equation for the sum of squared deviations is:

DEVSQ=\sum_{i=1}^N(x_i-\overline{x})^2
(1)

where: {x_1, x_2 ..., x_N} is a set of data and \overline{x} is the arithmetic mean.

References

Example 1

#include <codecogs/statistics/moments/squared_deviations.h>
#include <iostream>

int main()
{
  int x[5] = {4 , 5 , 8 , 6 , 3};
  double sq = Stats::Moments::devsq<int>(5, x);
  std::cout << "The sum of squared deviations is: " << sq << std::endl;
  return 0;
}

Output:

The sum of squared deviations is: 14.8

Parameters

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

Returns

sum of squared deviations of the given set of data
GPL Licence — free for non commercial use. See Licence details.