In statistics, skewness and kurtosis are two ways to measure the shape of a distribution.
Skewness is a measure of the asymmetry of a distribution. This value can be positive or negative.
- A negative skew indicates that the tail is on the left side of the distribution, which extends towards more negative values.
- A positive skew indicates that the tail is on the right side of the distribution, which extends towards more positive values.
- A value of zero indicates that there is no skewness in the distribution at all, meaning the distribution is perfectly symmetrical.
Kurtosis is a measure of whether or not a distribution is heavy-tailed or light-tailed relative to a normal distribution.
- The kurtosis of a normal distribution is 3.
- If a given distribution has a kurtosis less than 3, it is said to be playkurtic, which means it tends to produce fewer and less extreme outliers than the normal distribution.
- If a given distribution has a kurtosis greater than 3, it is said to be leptokurtic, which means it tends to produce more outliers than the normal distribution.
Note: Some formulas (Fisher’s definition) subtract 3 from the kurtosis to make it easier to compare with the normal distribution. Using this definition, a distribution would have kurtosis greater than a normal distribution if it had a kurtosis value greater than 0.
This tutorial explains how to calculate both the skewness and kurtosis of a given dataset in Python.
Example: Skewness & Kurtosis in Python
Suppose we have the following dataset:
data = [88, 85, 82, 97, 67, 77, 74, 86, 81, 95, 77, 88, 85, 76, 81]
- skew(array of values, bias=False)
- kurt(array of values, bias=False)
We use the argument bias=False to calculate the sample skewness and kurtosis as opposed to the population skewness and kurtosis.
Here is how to use these functions for our particular dataset:
data = [88, 85, 82, 97, 67, 77, 74, 86, 81, 95, 77, 88, 85, 76, 81] #calculate sample skewness skew(data, bias=False) 0.032697 #calculate sample kurtosis kurtosis(data, bias=False) 0.118157
The skewness turns out to be 0.032697 and the kurtosis turns out to be 0.118157.
This means the distribution is slightly positively skewed and the distribution has more values in the tails compared to a normal distribution.
Additional Resource: Skewness & Kurtosis Calculator
You can also calculate the skewness for a given dataset using the Statology Skewness and Kurtosis Calculator, which automatically calculates both the skewness and kurtosis for a given dataset.