Moments
- Moment I: Mean
- Moment II: Variance
- Moment III: Skew
- Moment IV: kurtosis# Moments: Mean, Variance, Skew, Kurtosis Moments are a few calculations that describe key characteristics of a data distribution
In [7]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as sp
In [8]:
vals = np.random.normal(0, 0.5, 10000)
plt.hist(vals, 50)
plt.show()
In [9]:
np.mean(vals)
Out [9]:
Moment II: Variance
The spread between numbers in a dataset.In [10]:
np.var(vals)
Out [10]:
Moment III: Skew
How "lopsided" or "asymmetrical" a dataset's distribution is.0 skew is symmetrical. Normal distributions have a 0 value.
Positive skew refers to data where the "right" side of the data beyond it's peak is longer than the left.
Negative skew refers to data where the "left" side of the data beyond it's peak is longer than the right.
In [11]:
sp.skew(vals)
Out [11]:
Moment IV: kurtosis
The definition of Kurtosis seems a bit convoluted.Kurtosis can help differentiate between distributions.
A dataset with normal distribution has a kurtosis value of 3. This is called mesokurtic.
A dataset with kurtosis > 3 are called leptokurtic. These have a longer tail than normal distributions. These are "pointier" at their peak.
Distributions with kurtosis < 3 are called platykurtic. These have even longer tails than leptokurtic, and are "broader" at their peak.
Kurtosis ranges from 1 to Infinity.
In [12]:
sp.kurtosis(vals)
Out [12]:
Page Tags:
python
data-science
jupyter
learning
numpy