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): μ=1n∑i=1nxi\mu = \frac{1}{n} \sum_{i=1}^{n} x_i

Variance — spread around the mean (second moment, sample): s2=1n−1∑i=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σ4−3\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.