DEV Community

Njeri Kimaru
Njeri Kimaru

Posted on

Skewness and kurtosis

If you've ever looked at a histogram and thought, "Hmm... this looks weirdly stretched or tilted," you're not alone. What you're noticing might be skewness or kurtosis โ€” two important concepts in statistics that describe the shape of a distribution.

๐Ÿ“ˆ What is Skewness?

Skewness tells us about the asymmetry of a distribution.

positive skewed:

Tail stretches more on the right. Mean > Median.

negatively skewed:

Tail stretches more on the left. Mean < Median.

Zero skewness:

Perfectly symmetrical (like a normal distribution).

๐Ÿ’ก Example in Python:

python

```import scipy.stats as stats
import numpy as np

data = np.random.exponential(scale=2, size=1000)
print("Skewness:", stats.skew(data))

๐ŸŽฏ What is Kurtosis?

Kurtosis measures the "tailedness" of the distribution โ€” how extreme the outliers are.

High kurtosis (leptokurtic):

Heavy tails (more outliers).

Low kurtosis (platykurtic):

Light tails (fewer outliers).

Normal kurtosis (mesokurtic):

~3 (for normal distribution).

๐Ÿ’ก Python Example:
print("Kurtosis:", stats.kurtosis(data, fisher=False))


`import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import kurtosis, skew
Enter fullscreen mode Exit fullscreen mode

Top comments (0)