@@ -96,8 +96,9 @@ The package [QuantEcon.py](https://github.com/QuantEcon/QuantEcon.py), already i
9696To illustrate, suppose that
97979898```{code-cell} ipython3
99+rng = np.random.default_rng()
99100n = 10_000 # size of sample
100-w = np.exp(np.random.randn(n)) # lognormal draws
101+w = np.exp(rng.standard_normal(n)) # lognormal draws
101102```
102103103104is data representing the wealth of 10,000 households.
@@ -137,7 +138,7 @@ a_vals = (1, 2, 5) # Pareto tail index
137138n = 10_000 # size of each sample
138139fig, ax = plt.subplots()
139140for a in a_vals:
140- u = np.random.uniform(size=n)
141+ u = rng.uniform(size=n)
141142 y = u**(-1/a) # distributed as Pareto with tail index a
142143 f_vals, l_vals = qe.lorenz_curve(y)
143144 ax.plot(f_vals, l_vals, label=f'$a = {a}$')
@@ -177,7 +178,7 @@ n = 100
177178178179fig, ax = plt.subplots()
179180for a in a_vals:
180- y = np.random.weibull(a, size=n)
181+ y = rng.weibull(a, size=n)
181182 ginis.append(qe.gini_coefficient(y))
182183 ginis_theoretical.append(1 - 2**(-1/a))
183184ax.plot(a_vals, ginis, label='estimated gini coefficient')
@@ -561,13 +562,14 @@ Here is one solution, which produces a good match between theory and
561562simulation.
562563563564```{code-cell} ipython3
565+rng = np.random.default_rng()
564566a_vals = np.linspace(1, 10, 25) # Pareto tail index
565567ginis = np.empty_like(a_vals)
566568567569n = 1000 # size of each sample
568570fig, ax = plt.subplots()
569571for i, a in enumerate(a_vals):
570- y = np.random.uniform(size=n)**(-1/a)
572+ y = rng.uniform(size=n)**(-1/a)
571573 ginis[i] = qe.gini_coefficient(y)
572574ax.plot(a_vals, ginis, label='sampled')
573575ax.plot(a_vals, 1/(2*a_vals - 1), label='theoretical')