reservoirpy.datasets.narma#

reservoirpy.datasets.narma(n_timesteps, order=30, a1=0.2, a2=0.04, b=1.5, c=0.001, x0=[0.0], seed=None, u=None)[source]#

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]\).

Note

In most reservoir computing benchmarks, $u$ is given as an input. If you want access to its value, you should create the u array and pass it as an argument to the function as shown below. This choice is made to avoid breaking changes. In future ReservoirPy versions, u will be returned with y. See related discussion.

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). See above note.

Returns:

NARMA timeseries.

Return type:

array of shape (n_timesteps, 1)

Example

>>> import numpy as np
>>> from reservoirpy.nodes import Reservoir, Ridge
>>> from reservoirpy.datasets import narma
>>> model = Reservoir(100) >> Ridge()
>>> n_timesteps, order = 2000, 30
>>> rng = np.random.default_rng(seed=2341)
>>> u = rng.uniform(0, 0.5, size=(n_timesteps + order, 1))
>>> y = narma(n_timesteps=n_timesteps, order=order, u=u)
>>> model = model.fit(u[order:], y)

References