Skip to content

Commit 73aab7b

Browse files
committed
Update inequality.md
Hi Matt, I have updated the solution and in the main text by adding ` %%time`. What do you think about this comparison?
1 parent 6daf793 commit 73aab7b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lectures/inequality.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ You can check this by looking up the expression for the mean of a lognormal
481481
distribution.
482482

483483
```{code-cell} ipython3
484+
%%time
484485
k = 5
485486
σ_vals = np.linspace(0.2, 4, k)
486487
n = 2_000
@@ -1161,14 +1162,15 @@ n = 2_000
11611162
μ_vals = -σ_vals**2/2
11621163
y_vals = np.exp(μ_vals + σ_vals*np.random.randn(n))
11631164
```
1164-
We can compute the Gini coefficient for these five populations using the vectorized function as follows,
1165+
We can compute the Gini coefficient for these five populations using the vectorized function, the computation time is shown below:
11651166

11661167
```{code-cell} ipython3
1168+
%%time
11671169
gini_coefficients =[]
11681170
for i in range(k):
1169-
gini_coefficients.append(gini(simulated_data[i]))
1171+
gini_coefficients.append(gini(y_vals[i]))
11701172
```
1171-
1173+
This shows the vectorized function is much faster.
11721174
This gives us the Gini coefficients for these five households.
11731175

11741176
```{code-cell} ipython3

0 commit comments

Comments
 (0)