Skip to content

Instantly share code, notes, and snippets.

@andiac
Created February 17, 2022 20:50
Show Gist options
  • Save andiac/8d19be6c8b059cd88c980f6391697638 to your computer and use it in GitHub Desktop.
Save andiac/8d19be6c8b059cd88c980f6391697638 to your computer and use it in GitHub Desktop.
Generate brownian bridge
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)
@andiac
Copy link
Author

andiac commented Feb 17, 2022

brownian_bridge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment