Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .translate/state/wealth_dynamics.md.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source-sha: 39b39c9bcb4363353b27e2180f12551fbd3a6e9f
synced-at: "2026-07-18"
source-sha: fccf5a9fd50129b3b03a4fd7b5d04976ac51e3a5
synced-at: "2026-07-21"
model: claude-sonnet-5
mode: RESYNC
section-count: 6
tool-version: 0.17.0
tool-version: 0.20.0
16 changes: 10 additions & 6 deletions lectures/wealth_dynamics.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ from numba.experimental import jitclass

上面已经导入的[QuantEcon.py](https://github.com/QuantEcon/QuantEcon.py)包含了计算洛伦兹曲线的函数。

举例说明,假设以下数据代表了10,000个家庭的财富分布
举例说明,假设

```{code-cell} ipython3
rng = np.random.default_rng()
n = 10_000 # 样本大小
w = np.exp(np.random.randn(n)) # 生成对数正态分布的随机样本
w = np.exp(rng.standard_normal(n)) # 生成对数正态分布的随机样本
```

是代表10,000个家庭财富的数据。

我们可以按如下方式计算并绘制洛伦兹曲线:

```{code-cell} ipython3
Expand Down Expand Up @@ -147,7 +150,7 @@ a_vals = (1, 2, 5) # 帕累托分布的尾部指数
n = 10_000 # 每个样本的大小
fig, ax = plt.subplots()
for a in a_vals:
u = np.random.uniform(size=n)
u = rng.uniform(size=n)
y = u**(-1/a) # 服从尾部指数为a的帕累托分布
f_vals, l_vals = qe.lorenz_curve(y)
ax.plot(f_vals, l_vals, label=f'$a = {a}$')
Expand Down Expand Up @@ -184,7 +187,7 @@ n = 100

fig, ax = plt.subplots()
for a in a_vals:
y = np.random.weibull(a, size=n)
y = rng.weibull(a, size=n)
ginis.append(qe.gini_coefficient(y))
ginis_theoretical.append(1 - 2**(-1/a))
ax.plot(a_vals, ginis, label='基尼系数估值')
Expand Down Expand Up @@ -543,13 +546,14 @@ plt.show()
这是一个解法,它在理论和模拟之间产生了很好的匹配。

```{code-cell} ipython3
rng = np.random.default_rng()
a_vals = np.linspace(1, 10, 25) # 帕累托尾部指数
ginis = np.empty_like(a_vals)

n = 1000 # 每个样本的大小
fig, ax = plt.subplots()
for i, a in enumerate(a_vals):
y = np.random.uniform(size=n)**(-1/a)
y = rng.uniform(size=n)**(-1/a)
ginis[i] = qe.gini_coefficient(y)
ax.plot(a_vals, ginis, label='抽样值')
ax.plot(a_vals, 1/(2*a_vals - 1), label='理论值')
Expand Down Expand Up @@ -630,4 +634,4 @@ plt.show()
```

```{solution-end}
```
```
Loading