Tool

Data-fit lab

Choose one of the lab's datasets and a distribution to fit to it. The histogram shows the data with the fitted curve over it; the Q-Q plot puts the data's quantiles against the fit's, so a good fit lies along the line and a bad one bends away from it. For a normal fit, the tail table counts the values far from the mean and compares them with what the normal expects.

Goes with chapter 7. The normal distribution

Dataset

The 251 daily log returns of a simulated share over one year of trading, a crash included. Generated, not market data.

Download share-close.csv

Distribution to fit

Fitted: N(μ = 0.0012, σ = 0.0279)

norm(loc=x.mean(), scale=x.std(ddof=1))

Histogram and fit

Q-Q plot

Summary statistics

Values (n)251
Mean0.0012
Standard deviation0.0279
Smallest-0.1595
Lower quartile-0.0122
Median0.0018
Upper quartile0.013
Largest0.1243
Skewness-0.3923
Excess kurtosis6.7476
As pandas computes them: the standard deviation with n − 1, the quartiles by linear interpolation, the adjusted skewness and the excess kurtosis (0 for a normal).

The tails against the normal

Beyond Observed A normal expects
|z| > 2 15 11.4
|z| > 3 4 0.678
|z| > 4 2 0.016

The worst day, day 67: a log return of -0.1595, a fall of 14.7 %, at z = -5.76. The fitted normal gives a day at least this bad a probability of 4.23E-9.

How to read the plots

The Q-Q plot sorts the data and sets each value against the quantile the fitted distribution puts at the same position. If the fit is right, the points follow the dashed line. Points that bend below the line on the left and above it on the right mean the data have more extreme values than the fit, fat tails; an S the other way means thinner tails; a curve means skew.

The simulated share's returns lie along the line in the middle and leave it at both ends: the crash and the rebound are far more extreme than a normal with the same mean and standard deviation allows. The excess kurtosis, 0 for a normal, says the same in one number. The dose times, a sample that is close to normal, stay near the line throughout.

Try the bug-fix times with an exponential fit: the histogram is flat and the fit is not, and the Q-Q plot curves. A good-looking mean and standard deviation do not make a good fit; the shape has to match too.

From distributions to confidence intervals · step 3 of 10

The simulated share's fat tails

The same check on a year of daily log returns fails. The normal expects 0.68 days beyond 3 standard deviations; there were 4. The worst day, day 67, lies 5.76 standard deviations out. Ask what a risk manager should make of a model that fits the middle and misses the crashes.

All steps
An unhandled error has occurred. Reload ๐Ÿ—™

Reconnecting…

Your connection to Introduction to Probability Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.