Skip to content

Commit 971b327

Browse files
committed
update_inequality_exercise
Hi Matt, This commit select 3000 random sample from the original dataset. Best, Longye
1 parent 0aec0eb commit 971b327

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lectures/inequality.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ df_income_wealth.head(n=4)
10841084
We 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)
10941094
We 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

11001100
Now 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
```
11131113
Let's simulate five populations by drawing from a lognormal distribution as before
11141114

0 commit comments

Comments
 (0)