Created
February 17, 2022 20:50
-
-
Save andiac/8d19be6c8b059cd88c980f6391697638 to your computer and use it in GitHub Desktop.
Generate brownian bridge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib | |
import matplotlib.pyplot as plt | |
N = 10 | |
T = 300 | |
random_seed = 0 | |
np.random.seed(random_seed) | |
bs = [] | |
for i in range(N): | |
w = [0.0] | |
dt = 1.0 / T | |
for _ in range(T): | |
w.append(np.random.normal(w[-1], np.sqrt(dt))) | |
b = [] | |
for j in range(T + 1): | |
b.append(w[j] - w[-1] * j / T) | |
plt.plot(b) | |
plt.savefig("brownian_bridge.png", dpi=200) |
Author
andiac
commented
Feb 17, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment