SKEWNESS
This function measures distribution asymmetry using sample skewness.
Using central moments m_2 and m_3, the Fisher-Pearson skewness coefficient is:
g_1 = \frac{m_3}{m_2^{3/2}}
Positive skewness indicates a longer right tail, negative skewness indicates a longer left tail, and values near zero suggest approximate symmetry.
Excel Usage
=SKEWNESS(data, bias)
data(list[list], required): 2D array of numeric values. Non-numeric values are ignored.bias(bool, optional, default: true): If True, calculations are not corrected for statistical bias.
Returns (float): Skewness value (float), or error message string.
Example 1: Right skewed data returns positive skewness
Inputs:
| data | bias |
|---|---|
| 1 | true |
| 2 | |
| 3 | |
| 4 | |
| 10 |
Excel formula:
=SKEWNESS({1;2;3;4;10}, TRUE)
Expected output:
1.13842
Example 2: Left skewed data returns negative skewness
Inputs:
| data | bias |
|---|---|
| 1 | true |
| 7 | |
| 8 | |
| 9 | |
| 10 |
Excel formula:
=SKEWNESS({1;7;8;9;10}, TRUE)
Expected output:
-1.13842
Example 3: Symmetric data returns zero skewness (biased)
Inputs:
| data | bias |
|---|---|
| 1 | true |
| 2 | |
| 3 | |
| 4 | |
| 5 |
Excel formula:
=SKEWNESS({1;2;3;4;5}, TRUE)
Expected output:
0
Example 4: Symmetric data returns zero skewness (unbiased)
Inputs:
| data | bias |
|---|---|
| 1 | false |
| 2 | |
| 3 | |
| 4 | |
| 5 |
Excel formula:
=SKEWNESS({1;2;3;4;5}, FALSE)
Expected output:
0
Python Code
import math
from scipy.stats import skew as scipy_skew
def skewness(data, bias=True):
"""
Calculate the skewness of a dataset.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.skew.html
This example function is provided as-is without any representation of accuracy.
Args:
data (list[list]): 2D array of numeric values. Non-numeric values are ignored.
bias (bool, optional): If True, calculations are not corrected for statistical bias. Default is True.
Returns:
float: Skewness value (float), or error message string.
"""
def to2d(x):
return [[x]] if not isinstance(x, list) else x
try:
data = to2d(data)
if not isinstance(data, list) or not all(isinstance(row, list) for row in data) or not data:
return "Error: Invalid input: data must be a non-empty 2D list."
if not isinstance(bias, bool):
return "Error: Invalid input: bias must be a boolean."
flat_data = []
for row in data:
for item in row:
try:
val = float(item)
if math.isfinite(val):
flat_data.append(val)
except (ValueError, TypeError):
continue
if len(flat_data) < 3 and not bias:
return "Error: Invalid input: At least 3 data points are required for unbiased skewness calculation."
if len(flat_data) < 2:
return "Error: Invalid input: At least 2 data points are required for skewness calculation."
result = scipy_skew(flat_data, bias=bias)
return float(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
2D array of numeric values. Non-numeric values are ignored.
If True, calculations are not corrected for statistical bias.