File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -481,6 +481,7 @@ You can check this by looking up the expression for the mean of a lognormal
481
481
distribution.
482
482
483
483
``` {code-cell} ipython3
484
+ %%time
484
485
k = 5
485
486
σ_vals = np.linspace(0.2, 4, k)
486
487
n = 2_000
@@ -1161,14 +1162,15 @@ n = 2_000
1161
1162
μ_vals = -σ_vals**2/2
1162
1163
y_vals = np.exp(μ_vals + σ_vals*np.random.randn(n))
1163
1164
```
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:
1165
1166
1166
1167
``` {code-cell} ipython3
1168
+ %%time
1167
1169
gini_coefficients =[]
1168
1170
for i in range(k):
1169
- gini_coefficients.append(gini(simulated_data [i]))
1171
+ gini_coefficients.append(gini(y_vals [i]))
1170
1172
```
1171
-
1173
+ This shows the vectorized function is much faster.
1172
1174
This gives us the Gini coefficients for these five households.
1173
1175
1174
1176
``` {code-cell} ipython3
You can’t perform that action at this time.
0 commit comments