neurodsp.sim.sim_random_walk

neurodsp.sim.sim_random_walk(n_seconds, fs, theta=1.0, mu=0.0, sigma=5.0)[source]

Simulate a mean-reverting random walk, as an Ornstein-Uhlenbeck process.

Parameters
n_secondsfloat

Simulation time, in seconds.

fsfloat

Sampling rate of simulated signal, in Hz.

thetafloat, optional, default: 1.0

Memory scale parameter. Larger theta values create faster fluctuations.

mufloat, optional, default: 0.0

Mean of the random walk.

sigmafloat, optional, default: 5.0

Standard deviation of the random walk.

Returns
sig: 1d array

Simulated random walk signal.

Notes

The random walk is simulated as a discretized Ornstein-Uhlenbeck process:

dx = theta*(x-mu)*dt + sigma*dWt

Where:

  • mu : mean

  • sigma : standard deviation

  • theta : memory scale

  • dWt : increments of Wiener process, i.e. white noise

References

See the wikipedia page for the integral solution:

https://en.wikipedia.org/wiki/Ornstein%E2%80%93Uhlenbeck_process#Formal_solution

Examples

Simulate a Ornstein-Uhlenbeck random walk:

>>> sig = sim_random_walk(n_seconds=1, fs=500, theta=1.)

Examples using neurodsp.sim.sim_random_walk