FUNCTION
Skewness
Calculates the skewness of a given set of data.
You're viewing an older version of this page (#5374). View the current version.
Interface
#include <codecogs/statistics/moments/skewness.h>
using namespace Statistics::Moments;
Skewness is a measure of symmetry, or more precisely, the lack of symmetry. A distribution, or data set, is symmetric if it looks the same to the left and right of the center point. For univariate data $x_1, x_2, ..., x_N$, the formula for skewness is:
where $\overline{x}$ is the arithmetic mean, $\sigma$ is the population standard deviation (i.e. using N, not N-1, in its denominator), and N is the number of data points.
The skewness for a normal distribution is zero, and any symmetric data should have a skewness near zero. Negative values for the skewness indicate data that are skewed left and positive values for the skewness indicate data that are skewed right.
Example 1
#include <codecogs/statistics/moments/skewness.h>
#include <iostream>
int main()
{
float x[5] = {3.4 , 7.1 , 1.5 , 8.6 , 4.9};
double skew = Statistics::Moments::skewness<float>(5, x);
std::cout << "The population skewness is: " << skew << std::endl;
return 0;
}Output:
The population skewness is:-0.0107687