spectral_connectivity.simulate.simulate_lagged_broadband#
- simulate_lagged_broadband(lags: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], noise_levels: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], n_time_samples: int, n_trials: int | None = None, random_state: int | Generator | None = None) ndarray[tuple[int, ...], dtype[floating]][source]#
Noisy copies of one white-noise source, each delayed by whole samples.
Signal
kissource[t - lags[k]] + noise_levels[k] * N(0, 1), so a signal with a smaller lag leads one with a larger lag by their difference in samples. The source is broadband on purpose: a sinusoid delayed by a whole number of cycles is indistinguishable from the original and carries no lag information for group delay or the phase slope index.- Parameters:
lags (array_like of int, shape (n_signals,)) – Delay of each signal behind the source, in samples. Must be non-negative integers; express a lead as a smaller lag on the leading signal, e.g.
lags=(0, 3)for signal 0 leading signal 1 by 3 samples.noise_levels (float or array_like of float, shape (n_signals,)) – Standard deviation of the independent Gaussian noise added to each signal. A scalar applies to every signal; 0 gives the pure delayed source.
n_time_samples (int) – Number of time samples per signal.
n_trials (int or None, optional) – Number of independent trials. None (default) omits the trial axis.
random_state (int, np.random.Generator, or None, optional) – Seed or generator for reproducible results.
- Returns:
time_series – The delayed noisy copies; the trial axis is present only when
n_trialsis given.- Return type:
NDArray[floating], shape (n_time_samples, n_signals) or (n_time_samples, n_trials, n_signals)
- Raises:
ValueError – If any lag is negative or not an integer, or if
noise_levelsis neither a scalar nor one value per signal.
Notes
The source has
n_time_samples + max(lags)samples and signalkis its slice starting atmax(lags) - lags[k], so no sample wraps around. The source is drawn first, then all of the noise in one draw of shapetime_series.shape.Examples
>>> import numpy as np >>> time_series = simulate_lagged_broadband( ... lags=(0, 3), noise_levels=0.0, n_time_samples=100, random_state=0 ... ) >>> time_series.shape (100, 2) >>> # Signal 1 repeats signal 0 three samples later: signal 0 leads. >>> bool(np.array_equal(time_series[3:, 1], time_series[:-3, 0])) True