| 1 |
#!/usr/bin/env python3 |
| 2 |
""" |
| 3 |
Ornstein-Uhlenbeck process |
| 4 |
|
| 5 |
Figure 2: Two realizations of the Ornstein-Uhlenbeck process for |
| 6 |
parameters τ=1.0 and σ=0.1 (black curve), and for τ=0.1 and σ=0.31622 |
| 7 |
(red curve). In both cases the noise intensity is σ^2*τ=0.01 . The red |
| 8 |
curve represents a noise that more closely mimics Gaussian white |
| 9 |
noise. Both realizations begin here at x(0)=1.0 , after which the mean |
| 10 |
decays exponentially to zero with time constant τ. |
| 11 |
|
| 12 |
Andre Longtin (2010) Stochastic dynamical systems. Scholarpedia, 5(4):1619. |
| 13 |
|
| 14 |
Sebastian Schmitt, 2022 |
| 15 |
""" |
| 16 |
|
| 17 |
import matplotlib.pyplot as plt |
| 18 |
import numpy as np |
| 19 |
|
| 20 |
from brian2 import run |
| 21 |
from brian2 import NeuronGroup, StateMonitor |
| 22 |
from brian2 import second, ms |
| 23 |
|
| 24 |
N = NeuronGroup( |
| 25 |
2, |
| 26 |
""" |
| 27 |
tau : second |
| 28 |
sigma : 1 |
| 29 |
dy/dt = -y/tau + sqrt(2*sigma**2/tau)*xi : 1 |
| 30 |
""", |
| 31 |
method="euler" |
| 32 |
) |
| 33 |
|
| 34 |
N.tau = np.array([1, 0.1]) * second |
| 35 |
N.sigma = np.array([0.1, 0.31622]) |
| 36 |
N.y = 1 |
| 37 |
|
| 38 |
M = StateMonitor(N, "y", record=True) |
| 39 |
|
| 40 |
run(10 * second) |
| 41 |
|
| 42 |
plt.plot(M.t / second, M.y[1], color="red", label=r"$\tau$=0.1 s, $\sigma$=0.31622") |
| 43 |
plt.plot(M.t / second, M.y[0], color="k", label=r"$\tau$=1 s, $\sigma$=0.1") |
| 44 |
|
| 45 |
plt.xlim(0, 10) |
| 46 |
plt.ylim(-1.1, 1.1) |
| 47 |
|
| 48 |
plt.xlabel("time (sec)") |
| 49 |
plt.ylabel("Ornstein-Uhlenbeck process") |
| 50 |
|
| 51 |
plt.legend() |
| 52 |
|
| 53 |
plt.show() |