Skip to content

Commit 3869dfa

Browse files
authored
🌐 [translation-sync] [perm_income.md] Update np.random → Generator API (#199)
* Update translation: lectures/perm_income.md * Update translation: .translate/state/perm_income.md.yml
1 parent 161fbdd commit 3869dfa

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
source-sha: a73ba0f7db0a6783ab5b9cca269a9f95f88106cb
2-
synced-at: "2025-06-17"
3-
model: unknown
4-
mode: RESYNC
1+
source-sha: ab687aad2134b4eee2835f896be4b956e73001bb
2+
synced-at: "2026-07-23"
3+
model: claude-sonnet-5
4+
mode: UPDATE
55
section-count: 6
6-
tool-version: 0.20.0
6+
tool-version: 0.22.0

lectures/perm_income.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ r = 0.05
501501
T = 60
502502
503503
@jit
504-
def time_path(T):
505-
w = np.random.randn(T+1) # w_0, w_1, ..., w_T
504+
def time_path(T, rng):
505+
w = rng.standard_normal(T+1) # w_0, w_1, ..., w_T
506506
w[0] = 0
507507
b = np.zeros(T+1)
508508
for t in range(1, T+1):
@@ -511,7 +511,8 @@ def time_path(T):
511511
c = μ + (1 - β) * (σ * w - b)
512512
return w, b, c
513513
514-
w, b, c = time_path(T)
514+
rng = np.random.default_rng()
515+
w, b, c = time_path(T, rng)
515516
516517
fig, ax = plt.subplots(figsize=(10, 6))
517518
@@ -534,7 +535,7 @@ fig, ax = plt.subplots(figsize=(10, 6))
534535
535536
b_sum = np.zeros(T+1)
536537
for i in range(250):
537-
w, b, c = time_path(T) # Generate new time path
538+
w, b, c = time_path(T, rng) # Generate new time path
538539
rcolor = random.choice(('c', 'g', 'b', 'k'))
539540
ax.plot(c, color=rcolor, lw=0.8, alpha=0.7)
540541
@@ -1025,4 +1026,3 @@ $$
10251026
[^f5]: 如果由$y^t$张成的线性空间等于由$w^t$张成的线性空间,则过程$y_t$的移动平均表示被称为**基本的**。通过卡尔曼滤波获得的时不变创新表示在构造上是基本的。
10261027

10271028
[^f8]: 相关思想的有趣应用请参见{cite}`CampbellShiller88`、{cite}`LettLud2001`、{cite}`LettLud2004`
1028-

0 commit comments

Comments
 (0)