Skip to content

Commit 7c99b66

Browse files
authored
Update ogm_crra.py
1 parent 003dfba commit 7c99b66

File tree

1 file changed

+15
-15
lines changed
  • lectures/_static/lecture_specific/optgrowth_fast

1 file changed

+15
-15
lines changed

lectures/_static/lecture_specific/optgrowth_fast/ogm_crra.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
from numba.experimental import jitclass
33

44
opt_growth_data = [
5-
('α', float64), # Production parameter
6-
('β', float64), # Discount factor
7-
('μ', float64), # Shock location parameter
8-
('γ', float64), # Preference parameter
9-
('s', float64), # Shock scale parameter
10-
('grid', float64[:]), # Grid (array)
11-
('shocks', float64[:]) # Shock draws (array)
5+
('α', float64), # 生产参数
6+
('β', float64), # 折现因子
7+
('μ', float64), # 冲击的均值参数
8+
('γ', float64), # 偏好参数
9+
('s', float64), # 冲击的尺度参数
10+
('grid', float64[:]), # 网格(数组)
11+
('shocks', float64[:]) # 冲击样本(数组)
1212
]
1313

1414
@jitclass(opt_growth_data)
@@ -27,29 +27,29 @@ def __init__(self,
2727

2828
self.α, self.β, self.γ, self.μ, self.s = α, β, γ, μ, s
2929

30-
# Set up grid
30+
# 设置网格
3131
self.grid = np.linspace(1e-5, grid_max, grid_size)
3232

33-
# Store shocks (with a seed, so results are reproducible)
33+
# 存储冲击(设置随机种子以确保结果可重复)
3434
np.random.seed(seed)
3535
self.shocks = np.exp(μ + s * np.random.randn(shock_size))
3636

37-
3837
def f(self, k):
39-
"The production function."
38+
"生产函数"
4039
return k**self.α
4140

4241
def u(self, c):
43-
"The utility function."
42+
"效用函数"
4443
return c**(1 - self.γ) / (1 - self.γ)
4544

4645
def f_prime(self, k):
47-
"Derivative of f."
46+
"生产函数的一阶导数"
4847
return self.α * (k**(self.α - 1))
4948

5049
def u_prime(self, c):
51-
"Derivative of u."
50+
"效用函数的一阶导数"
5251
return c**(-self.γ)
5352

54-
def u_prime_inv(c):
53+
def u_prime_inv(self, c):
54+
"效用函数一阶导数的反函数"
5555
return c**(-1 / self.γ)

0 commit comments

Comments
 (0)