Lesson 2 of 15

Mean, Variance, Skewness, Kurtosis

Statistical Moments

The moments of a distribution describe its shape. The first four moments are the foundation of quantitative analysis:

Mean — the average (first moment): μ=1ni=1nxi\mu = \frac{1}{n} \sum_{i=1}^{n} x_i

Variance — spread around the mean (second moment, sample): s2=1n1i=1n(xiμ)2s^2 = \frac{1}{n-1} \sum_{i=1}^{n} (x_i - \mu)^2

Skewness — asymmetry (third standardized moment): skew=1n(xiμ)3σ3\text{skew} = \frac{\frac{1}{n} \sum (x_i - \mu)^3}{\sigma^3}

where σ\sigma is the population standard deviation.

Excess Kurtosis — tail heaviness (fourth standardized moment minus 3): kurt=1n(xiμ)4σ43\text{kurt} = \frac{\frac{1}{n} \sum (x_i - \mu)^4}{\sigma^4} - 3

A normal distribution has skewness = 0 and excess kurtosis = 0.

Your Task

Implement all four moment functions. Use sample variance (divide by n-1) but population std (divide by n) for skewness and kurtosis normalization.

Python runtime loading...
Loading...
Click "Run" to execute your code.