GitHub

Original file line numberDiff line numberDiff line change

@@ -278,15 +278,15 @@ class UncertaintyTrapEcon:

278278

"""

279279

self.θ = self.ρ * self.θ + self.σ_θ * w

280280
281-

def gen_aggregates(self):

281+

def gen_aggregates(self, rng):

282282

"""

283283

Generate aggregates based on current beliefs (μ, γ). This

284284

is a simulation step that depends on the draws for F.

285285

"""

286-

F_vals = self.σ_F * np.random.randn(self.num_firms)

286+

F_vals = self.σ_F * rng.standard_normal(self.num_firms)

287287

M = np.sum(self.ψ(F_vals) > 0) # Counts number of active firms

288288

if M > 0:

289-

x_vals = self.θ + self.σ_x * np.random.randn(M)

289+

x_vals = self.θ + self.σ_x * rng.standard_normal(M)

290290

X = x_vals.mean()

291291

else:

292292

X = 0

@@ -444,10 +444,11 @@ M_vec = np.empty(sim_length)

444444

γ_vec[0] = econ.γ

445445

θ_vec[0] = 0

446446
447-

w_shocks = np.random.randn(sim_length)

447+

rng = np.random.default_rng()

448+

w_shocks = rng.standard_normal(sim_length)

448449
449450

for t in range(sim_length-1):

450-

X, M = econ.gen_aggregates()

451+

X, M = econ.gen_aggregates(rng)

451452

X_vec[t] = X

452453

M_vec[t] = M

453454

@@ -459,7 +460,7 @@ for t in range(sim_length-1):

459460

θ_vec[t+1] = econ.θ

460461
461462

# Record final values of aggregates

462-

X, M = econ.gen_aggregates()

463+

X, M = econ.gen_aggregates(rng)

463464

X_vec[-1] = X

464465

M_vec[-1] = M

465466

```

Read the original on github.com ↗