Skip to content

Features | latest | skewness

Skewness

Skewness is a statistical measure that quantifies the asymmetry of a dataset's probability distribution relative to its mean. It indicates the direction and degree of skew (departure from symmetry) in the distribution, helping to identify whether data values are concentrated more on one side of the mean.

  • Positive skewness: The distribution has a long tail on the right side (values greater than the mean).
  • Negative skewness: The distribution has a long tail on the left side (values less than the mean).
  • Zero skewness: The distribution is symmetric.

The skewness is calculated using the third and second central moment:

Skewness=m3m23,

where:

  • mk is the k-th central moment:

    mk=1Ni=0N1(x[i]x)k,

    with k=3 for skewness and k=2 for variance.

  • x is the mean of the dataset:

    x=1Ni=0N1x[i].
  • N is the number of data points in the dataset.

References

Code

INFO

The following snippet is written in a generic and unoptimized manner. The code aims to be comprehensible to programmers familiar with various programming languages and may not represent the most efficient or idiomatic Python practices. Please refer to implementations for optimized implementations in different programming languages.

py
import numpy as np


def skewness(signal: np.ndarray) -> float:
    def central_moment(order: int):
        return np.mean((signal - signal.mean()) ** order)

    return central_moment(3) / central_moment(2) ** (3 / 2)
Run in playground