You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -630,6 +635,36 @@ approximately linear in a log-log plot.
630
635
631
636
We will use this idea [below](https://intro.quantecon.org/heavy_tails.html#heavy-tails-in-economic-cross-sections) when we look at real data.
632
637
638
+
+++
639
+
640
+
#### Q-Q Plots
641
+
642
+
We can also use a [qq plot](https://en.wikipedia.org/wiki/Q%E2%80%93Q_plot) to do a visual comparison between two probability distributions.
643
+
644
+
The [statsmodels](https://www.statsmodels.org/stable/index.html) package provides a convenient [qqplot](https://www.statsmodels.org/stable/generated/statsmodels.graphics.gofplots.qqplot.html) function that, by default, compares sample data to the quintiles of the normal distribution.
645
+
646
+
If the data is drawn from a Normal distribution, the plot would look like:
647
+
648
+
```{code-cell} ipython3
649
+
data_normal = np.random.normal(size=sample_size)
650
+
sm.qqplot(data_normal, line='45')
651
+
plt.show()
652
+
```
653
+
654
+
We can now compare this with the exponential, log-normal, and pareto distributions
655
+
656
+
```{code-cell} ipython3
657
+
# Build figure
658
+
fig, axes = plt.subplots(3, 1, figsize=(6, 8))
659
+
axes = axes.flatten()
660
+
labels = ['exponential', 'lognormal', 'Pareto']
661
+
for data, label, ax in zip(data_list, labels, axes):
0 commit comments