@@ -479,8 +479,8 @@ r = 0.05
|
479 | 479 | T = 60 |
480 | 480 | |
481 | 481 | @jit |
482 | | -def time_path(T): |
483 | | - w = np.random.randn(T+1) # w_0, w_1, ..., w_T |
| 482 | +def time_path(T, rng): |
| 483 | + w = rng.standard_normal(T+1) # w_0, w_1, ..., w_T |
484 | 484 | w[0] = 0 |
485 | 485 | b = np.zeros(T+1) |
486 | 486 | for t in range(1, T+1): |
@@ -489,7 +489,8 @@ def time_path(T):
|
489 | 489 | c = μ + (1 - β) * (σ * w - b) |
490 | 490 | return w, b, c |
491 | 491 | |
492 | | -w, b, c = time_path(T) |
| 492 | +rng = np.random.default_rng() |
| 493 | +w, b, c = time_path(T, rng) |
493 | 494 | |
494 | 495 | fig, ax = plt.subplots(figsize=(10, 6)) |
495 | 496 | |
@@ -512,7 +513,7 @@ fig, ax = plt.subplots(figsize=(10, 6))
|
512 | 513 | |
513 | 514 | b_sum = np.zeros(T+1) |
514 | 515 | for i in range(250): |
515 | | - w, b, c = time_path(T) # Generate new time path |
| 516 | + w, b, c = time_path(T, rng) # Generate new time path |
516 | 517 | rcolor = random.choice(('c', 'g', 'b', 'k')) |
517 | 518 | ax.plot(c, color=rcolor, lw=0.8, alpha=0.7) |
518 | 519 | |
|