Skip to content

Commit 33e1c5f

Browse files
Update rng usage in samuelson.md
1 parent 370a58f commit 33e1c5f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

lectures/samuelson.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ def simulate_samuelson(
606606
607607
# Generate shocks if stochastic
608608
if σ > 0:
609-
np.random.seed(seed)
610-
ϵ = np.random.normal(0, 1, n)
609+
rng = np.random.default_rng(seed)
610+
ϵ = rng.normal(0, 1, n)
611611
612612
# Simulate forward
613613
for t in range(2, n):
@@ -1190,7 +1190,8 @@ C[1] = σ # Shock variance
11901190
11911191
sam_t = LinearStateSpace(A, C, G, mu_0=μ_0)
11921192
1193-
x, y = sam_t.simulate(ts_length=n)
1193+
rng = np.random.default_rng()
1194+
x, y = sam_t.simulate(ts_length=n, random_state=rng)
11941195
11951196
fig, axes = plt.subplots(3, 1, sharex=True, figsize=(12, 8))
11961197
titles = ["Output ($Y_t$)", "Consumption ($C_t$)", "Investment ($I_t$)"]
@@ -1303,8 +1304,8 @@ class SamuelsonLSS(LinearStateSpace):
13031304
except ValueError:
13041305
print("Stationary distribution does not exist")
13051306
1306-
np.random.seed(seed)
1307-
x, y = self.simulate(ts_length)
1307+
rng = np.random.default_rng(seed)
1308+
x, y = self.simulate(ts_length, random_state=rng)
13081309
13091310
fig, axes = plt.subplots(3, 1, sharex=True, figsize=(12, 8))
13101311
titles = ["Output ($Y_t$)",

0 commit comments

Comments
 (0)