File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -1084,7 +1084,7 @@ df_income_wealth.head(n=4)
10841084We will focus on wealth variable ` n_wealth ` to compute a Gini coefficient for the year 1990.
10851085
10861086``` {code-cell} ipython3
1087- data = df_income_wealth[df_income_wealth.year == 2016]
1087+ data = df_income_wealth[df_income_wealth.year == 2016].sample(3000, random_state=1)
10881088```
10891089
10901090``` {code-cell} ipython3
@@ -1094,7 +1094,7 @@ data.head(n=2)
10941094We can first compute the Gini coefficient using the function defined in the lecture above.
10951095
10961096``` {code-cell} ipython3
1097- gini_coefficient(data.n_wealth.values[1:3000] )
1097+ gini_coefficient(data.n_wealth.values)
10981098```
10991099
11001100Now we can write a vectorized version using ` numpy `
@@ -1108,7 +1108,7 @@ def gini(y):
11081108 return g_sum / (2 * n * np.sum(y))
11091109```
11101110``` {code-cell} ipython3
1111- gini(data.n_wealth.values[1:3000] )
1111+ gini(data.n_wealth.values)
11121112```
11131113Let's simulate five populations by drawing from a lognormal distribution as before
11141114
You can’t perform that action at this time.
0 commit comments