@@ -278,15 +278,15 @@ class UncertaintyTrapEcon:
|
278 | 278 | """ |
279 | 279 | self.θ = self.ρ * self.θ + self.σ_θ * w |
280 | 280 | |
281 | | - def gen_aggregates(self): |
| 281 | + def gen_aggregates(self, rng): |
282 | 282 | """ |
283 | 283 | Generate aggregates based on current beliefs (μ, γ). This |
284 | 284 | is a simulation step that depends on the draws for F. |
285 | 285 | """ |
286 | | - F_vals = self.σ_F * np.random.randn(self.num_firms) |
| 286 | + F_vals = self.σ_F * rng.standard_normal(self.num_firms) |
287 | 287 | M = np.sum(self.ψ(F_vals) > 0) # Counts number of active firms |
288 | 288 | if M > 0: |
289 | | - x_vals = self.θ + self.σ_x * np.random.randn(M) |
| 289 | + x_vals = self.θ + self.σ_x * rng.standard_normal(M) |
290 | 290 | X = x_vals.mean() |
291 | 291 | else: |
292 | 292 | X = 0 |
@@ -444,10 +444,11 @@ M_vec = np.empty(sim_length)
|
444 | 444 | γ_vec[0] = econ.γ |
445 | 445 | θ_vec[0] = 0 |
446 | 446 | |
447 | | -w_shocks = np.random.randn(sim_length) |
| 447 | +rng = np.random.default_rng() |
| 448 | +w_shocks = rng.standard_normal(sim_length) |
448 | 449 | |
449 | 450 | for t in range(sim_length-1): |
450 | | - X, M = econ.gen_aggregates() |
| 451 | + X, M = econ.gen_aggregates(rng) |
451 | 452 | X_vec[t] = X |
452 | 453 | M_vec[t] = M |
453 | 454 | |
@@ -459,7 +460,7 @@ for t in range(sim_length-1):
|
459 | 460 | θ_vec[t+1] = econ.θ |
460 | 461 | |
461 | 462 | # Record final values of aggregates |
462 | | -X, M = econ.gen_aggregates() |
| 463 | +X, M = econ.gen_aggregates(rng) |
463 | 464 | X_vec[-1] = X |
464 | 465 | M_vec[-1] = M |
465 | 466 | ``` |
|