Skip to content

Commit 003dfba

Browse files
authored
Update ogm.py
1 parent 6669861 commit 003dfba

File tree

1 file changed

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

1 file changed

+13
-13
lines changed

lectures/_static/lecture_specific/optgrowth_fast/ogm.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
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-
('s', float64), # Shock scale parameter
9-
('grid', float64[:]), # Grid (array)
10-
('shocks', float64[:]) # Shock draws (array)
5+
('α', float64), # 生产参数
6+
('β', float64), # 折现因子
7+
('μ', float64), # 冲击的均值参数
8+
('s', float64), # 冲击的尺度参数
9+
('grid', float64[:]), # 网格(数组)
10+
('shocks', float64[:]) # 冲击样本(数组)
1111
]
1212

1313
@jitclass(opt_growth_data)
@@ -25,32 +25,32 @@ def __init__(self,
2525

2626
self.α, self.β, self.μ, self.s = α, β, μ, s
2727

28-
# Set up grid
28+
# 设置网格
2929
self.grid = np.linspace(1e-5, grid_max, grid_size)
3030

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

3535

3636
def f(self, k):
37-
"The production function"
37+
"生产函数"
3838
return k**self.α
3939

4040

4141
def u(self, c):
42-
"The utility function"
42+
"效用函数"
4343
return np.log(c)
4444

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

4949

5050
def u_prime(self, c):
51-
"Derivative of u"
51+
"效用函数的一阶导数"
5252
return 1/c
5353

5454
def u_prime_inv(self, c):
55-
"Inverse of u'"
55+
"效用函数一阶导数的反函数"
5656
return 1/c

0 commit comments

Comments
 (0)