Skip to content

Algorithms | latest | skewness

Skewness

Skewness is a statistical measure that quantifies the asymmetry of the probability distribution of a dataset. It provides information about the direction and degree of skew (departure from symmetry) in the distribution. Skewness helps us understand whether the data is concentrated more to the left or right of the mean, and it is an important aspect of data analysis and statistics.

The skewness is computed using the third central moment:

Skewness=m3m23/2mk=1Ni=0N1(x[i]x)kx=1Ni=0N1x[i]

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