Skip to content
This repository was archived by the owner on Apr 24, 2020. It is now read-only.

Commit 31dcb7f

Browse files
committed
misc
1 parent 8f084ce commit 31dcb7f

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

source/rst/heavy_tails.rst

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Let's start with some imports:
7777
import matplotlib.pyplot as plt
7878
%matplotlib inline
7979
80-
from scipy.stats import cauchy
8180
8281
The following two lines can be added to avoid an annoying FutureWarning, and prevent a specific compatibility issue between pandas and matplotlib from causing problems down the line:
8382

@@ -202,24 +201,25 @@ whether or not the LLN is still valid.
202201

203202
.. code-block:: python3
204203
205-
n = 1000
204+
from scipy.stats import cauchy
205+
206206
np.random.seed(1234)
207+
N = 1_000
207208
208209
distribution = cauchy()
209210
210-
fig, ax = plt.subplots(figsize=(10, 6))
211-
data = distribution.rvs(n)
211+
fig, ax = plt.subplots()
212+
data = distribution.rvs(N)
212213
213214
# Compute sample mean at each n
214-
sample_mean = np.empty(n)
215-
216-
for i in range(1, n):
217-
sample_mean[i] = np.mean(data[:i])
215+
sample_mean = np.empty(N)
216+
for n in range(1, N):
217+
sample_mean[n] = np.mean(data[:n])
218218
219219
# Plot
220-
ax.plot(list(range(n)), sample_mean, 'r-', lw=3, alpha=0.6,
221-
label='$\\bar X_n$')
222-
ax.plot(list(range(n)), [0] * n, 'k--', lw=0.5)
220+
ax.plot(range(N), sample_mean, alpha=0.6, label='$\\bar X_n$')
221+
222+
ax.plot(range(N), np.zeros(N), 'k--', lw=0.5)
223223
ax.legend()
224224
225225
plt.show()
@@ -456,15 +456,11 @@ The Pareto distribution is assumed to take the form :eq:`pareto` with :math:`\ba
456456

457457
(The value the tail index :math:`\alpha` is plausible given the data :cite:`gabaix2016power`.)
458458

459-
To make the lognormal option as similar as possible to the Pareto option,
460-
choose its parameters such that the mean and median of both distributions are
461-
the same.
459+
To make the lognormal option as similar as possible to the Pareto option, choose its parameters such that the mean and median of both distributions are the same.
462460

463-
Note that, for each distribution, your estimate of tax revenue will be random
464-
because it is based on a finite number of draws.
461+
Note that, for each distribution, your estimate of tax revenue will be random because it is based on a finite number of draws.
465462

466-
To take this into account, generate 100 draws in each case and compare the two
467-
samples by
463+
To take this into account, generate 100 replications (evaluations of tax revenue) for each of the two distributions and compare the two samples by
468464

469465
* producing a `violin plot <https://en.wikipedia.org/wiki/Violin_plot>`__ visualizing the two samples side-by-side and
470466

0 commit comments

Comments
 (0)