neurodsp.sim.sim_random_walk

neurodsp.sim.sim_random_walk(n_seconds, fs, theta=1.0, mu=0.0, sigma=5.0, norm=True)[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

Scaling of the Wiener process (dWt).

normbool, optional, default: True

Whether to normalize the signal to the mean (mu) and variance ((sigma**2 / (2 * theta))).

Returns
sig1d 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 : Wiener scaling

  • theta : memory scale

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

The Wiener scaling (sigma) differs from the standard deviation of the signal. The standard deviation of the signal will instead equal: sigma / np.sqrt(2 * theta).

See the wikipedia page [1] for the integral solution.

References

1

https://en.wikipedia.org/wiki/Ornstein-Uhlenbeck_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

Simulating Aperiodic Signals

Simulating Aperiodic Signals