Skip to content

Commit 7e69a99

Browse files
authored
Add files via upload
1 parent ab31d3b commit 7e69a99

File tree

1 file changed

+78
-3
lines changed

1 file changed

+78
-3
lines changed

lectures/cass_koopmans_1.md

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ kernelspec:
5555
- 对于长期但有限期经济的最优路径的**收费公路**性质
5656
- **稳定流形****相位平面**
5757

58+
除了 Anaconda 中已有的库之外,本讲座还需要以下库:
59+
60+
```{code-cell} ipython
61+
:tags: [hide-output]
62+
!pip install quantecon
63+
```
64+
5865
让我们从一些标准导入开始:
5966

6067
```{code-cell} ipython3
@@ -711,7 +718,7 @@ plot_paths(pp, 0.3, k_ss/3, [150], k_ss=k_ss);
711718
```{code-cell} ipython3
712719
plot_paths(pp, 0.3, k_ss/3, [150, 75, 50, 25], k_ss=k_ss);
713720
```
714-
## 收费公路性质
721+
## 收费公路性质(Turnpike property)
715722
716723
以下计算表明,当 $T$ 非常大时,最优资本存量在大部分时间里都会保持在接近其稳态值的水平。
717724
@@ -726,11 +733,79 @@ plot_paths(pp, 0.3, k_ss/3, [250, 150, 50, 25], k_ss=k_ss);
726733
727734
对规划者来说,一个经验法则是:
728735
729-
- 从 $K_0$ 开始,将 $K_t$ 推向
730-
稳态,并在接近时间 $T$ 之前保持在稳态附近。
736+
- 从 $K_0$ 开始,将 $K_t$ 推向稳态,并在接近时间 $T$ 之前保持在稳态附近。
731737
732738
规划者通过调整储蓄率 $\frac{f(K_t) - C_t}{f(K_t)}$ 来实现这一目标。
733739
740+
```{exercise}
741+
:label: ck1_ex1
742+
743+
收费公路性质在 $T$ 足够大的情况下,与初始条件 $K_0$ 无关。
744+
745+
请扩展 `plot_paths` 函数,使其能够绘制多个初始点的轨迹,初始点取 `k0s = [k_ss*2, k_ss*3, k_ss/3]`。
746+
```
747+
748+
```{solution-start} ck1_ex1
749+
:class: dropdown
750+
```
751+
752+
参考答案
753+
754+
```{code-cell} ipython3
755+
def plot_multiple_paths(pp, c0, k0s, T_arr, k_ter=0, k_ss=None, axs=None):
756+
if axs is None:
757+
fig, axs = plt.subplots(1, 3, figsize=(16, 4))
758+
759+
ylabels = ['$c_t$', '$k_t$', r'$\mu_t$']
760+
titles = ['消费', '资本', '拉格朗日乘数']
761+
762+
colors = plt.cm.viridis(np.linspace(0, 1, len(k0s)))
763+
764+
all_c_paths = []
765+
all_k_paths = []
766+
767+
for i, k0 in enumerate(k0s):
768+
k0_c_paths = []
769+
k0_k_paths = []
770+
771+
for T in T_arr:
772+
c_vec, k_vec = bisection(pp, c0, k0, T, k_ter=k_ter, verbose=False)
773+
k0_c_paths.append(c_vec)
774+
k0_k_paths.append(k_vec)
775+
776+
μ_vec = pp.u_prime(c_vec)
777+
paths = [c_vec, k_vec, μ_vec]
778+
779+
for j in range(3):
780+
axs[j].plot(paths[j], color=colors[i],
781+
label=f'$k_0 = {k0:.2f}$' if j == 0 and T == T_arr[0] else "", alpha=0.7)
782+
axs[j].set(xlabel='t', ylabel=ylabels[j], title=titles[j])
783+
784+
if k_ss is not None and i == 0 and T == T_arr[0]:
785+
axs[1].axhline(k_ss, c='k', ls='--', lw=1)
786+
787+
axs[1].axvline(T+1, c='k', ls='--', lw=1)
788+
axs[1].scatter(T+1, paths[1][-1], s=80, color=colors[i])
789+
790+
all_c_paths.append(k0_c_paths)
791+
all_k_paths.append(k0_k_paths)
792+
793+
# 如果有多个初始点,添加图例
794+
if len(k0s) > 1:
795+
axs[0].legend()
796+
797+
return all_c_paths, all_k_paths
798+
```
799+
800+
```{code-cell} ipython3
801+
_ = plot_multiple_paths(pp, 0.3, [k_ss*2, k_ss*3, k_ss/3], [250, 150, 75, 50], k_ss=k_ss)
802+
```
803+
804+
我们看到,对于不同的初始值 $K_0$,收费公路性质都成立。
805+
806+
```{solution-end}
807+
```
808+
734809
让我们计算并绘制储蓄率。
735810
736811
```{code-cell} ipython3

0 commit comments

Comments
 (0)