Skip to content

Commit 43810d6

Browse files
committed
update distribution plot using code
1 parent e6c3d00 commit 43810d6

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

lectures/lake_model.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ plt.rcParams['font.family'] = ['Source Han Serif SC']
7676
plt.rcParams["figure.figsize"] = (11, 5) #设置默认图形大小
7777
import numpy as np
7878
from quantecon import MarkovChain
79-
from scipy.stats import norm
79+
import scipy.stats as stats
8080
from scipy.optimize import brentq
8181
from quantecon.distributions import BetaBinomial
8282
from numba import jit
@@ -616,10 +616,31 @@ $$
616616

617617
工资报价分布将采用对数正态分布 $LN(\log(20),1)$ 的离散化版本,如下图所示:
618618

619-
```{figure} /_static/lecture_specific/lake_model/lake_distribution_wages.png
620-
619+
```{code-cell} ipython3
620+
def create_wage_distribution(max_wage: float,
621+
wage_grid_size: int,
622+
log_wage_mean: float):
623+
"""Create wage distribution"""
624+
w_vec_temp = np.linspace(1e-8, max_wage,
625+
wage_grid_size + 1)
626+
cdf = stats.norm.cdf(np.log(w_vec_temp),
627+
loc=np.log(log_wage_mean), scale=1)
628+
pdf = cdf[1:] - cdf[:-1]
629+
p_vec = pdf / pdf.sum()
630+
w_vec = (w_vec_temp[1:] + w_vec_temp[:-1]) / 2
631+
return w_vec, p_vec
632+
633+
w_vec, p_vec = create_wage_distribution(170, 200, 20)
634+
635+
fig, ax = plt.subplots()
636+
ax.plot(w_vec, p_vec)
637+
ax.set_xlabel('工资')
638+
ax.set_ylabel('概率')
639+
plt.tight_layout()
640+
plt.show()
621641
```
622642

643+
623644
我们将一个时期设为一个月。
624645

625646
设定参数 $b$ 和 $d$ 分别为美国人口的月度[出生率](https://www.cdc.gov/nchs/fastats/births.htm)[死亡率](https://www.cdc.gov/nchs/fastats/deaths.htm)率:
@@ -784,16 +805,6 @@ d = 0.00822
784805
γ = 1.0
785806
σ = 2.0
786807
787-
# 默认工资分布 --- 离散化的对数正态
788-
log_wage_mean, wage_grid_size, max_wage = 20, 200, 170
789-
logw_dist = norm(np.log(log_wage_mean), 1)
790-
w_vec = np.linspace(1e-8, max_wage, wage_grid_size + 1)
791-
cdf = logw_dist.cdf(np.log(w_vec))
792-
pdf = cdf[1:] - cdf[:-1]
793-
p_vec = pdf / pdf.sum()
794-
w_vec = (w_vec[1:] + w_vec[:-1]) / 2
795-
796-
797808
def compute_optimal_quantities(c, τ):
798809
"""
799810
给定c和τ计算劳动者的保留工资、工作找到率和价值函数。
@@ -993,7 +1004,7 @@ class LakeModelModified:
9931004
9941005
9951006
def rate_steady_state(self, tol=1e-6):
996-
"""
1007+
r"""
9971008
找到系统 :math:`x_{t+1} = \hat A x_{t}` 的稳态
9981009
9991010
返回

0 commit comments

Comments
 (0)