Introduction to statsmodels
statsmodels is a Python library that allows us to explore data, perform statistical tests, and estimate statistical models.
This chapter focuses on statsmodels' modeling, analysis, and forecasting of time series.
Normal distribution test with Q-Q plots
An underlying assumption of many statistical learning techniques is that the observations/fields are normally distributed.
While there are many robust statistical tests for normal distributions, an intuitive visual method is known as a quantile-quantile plot (Q-Q plot). If a sample is normally distributed, its Q-Q plot is a straight line.
In the following code block, the statsmodels.graphics.api.qqplot(...)
method is used to check if a numpy.random.uniform(...)
distribution is normally distributed:
from statsmodels.graphics.api import qqplot import numpy as np fig = qqplot(np.random.uniform(size=10000), line='s') fig.set_size_inches(12, 6)
The resulting plot depicted in...