reservoirpy.datasets.narma#
- reservoirpy.datasets.narma(
- n_timesteps: int,
- order: int = 30,
- a1: float = 0.2,
- a2: float = 0.04,
- b: float = 1.5,
- c: float = 0.001,
- x0: list | ndarray = [0.0],
- seed: int | Generator | None = None,
- u: ndarray | None = None,
Non-linear Autoregressive Moving Average (NARMA) timeseries, as first defined in [14], and as used in [15].
NARMA n-th order dynamical system is defined by the recurrent relation:
\[y[t+1] = a_1 y[t] + a_2 y[t] (\sum_{i=0}^{n-1} y[t-i]) + b u[t-( n-1)]u[t] + c\]where \(u[t]\) are sampled following a uniform distribution in \([0, 0.5]\).
- Parameters:
n_timesteps (int) – Number of timesteps to generate.
order (int, default to 30) – Order of the system.
a1 (float, default to 0.2) – \(a_1\) parameter of the system.
a2 (float, default to 0.04) – \(a_2\) parameter of the system.
b (float, default to 1.5) – \(b\) parameter of the system.
c (float, default to 0.001) – \(c\) parameter of the system.
x0 (array-like of shape (init_steps,), default to [0.0]) – Initial conditions of the system.
seed (int or
numpy.random.Generator, optional) – Random state seed for reproducibility.u (array of shape (n_timesteps + order, 1), default to None.) – Input timeseries (usually uniformly distributed).
- Returns:
Input timeseries u and output NARMA timeseries.
- Return type:
tuple of arrays of shape (n_timesteps + order, 1) and (n_timesteps, 1)
Example
>>> import numpy as np >>> from reservoirpy.nodes import Reservoir, Ridge >>> from reservoirpy.datasets import narma >>> reservoir = Reservoir(100) >>> model = reservoir >> Ridge() >>> n_timesteps, order = 2000, 30 >>> rng = np.random.default_rng(seed=2341) >>> u, y = narma(n_timesteps=n_timesteps, order=order) >>> reservoir.run(u[:order]) # warmup >>> model = model.fit(u[order:], y)
References