fuzzyclust.timeseries.false_nearest_neighbors#

fuzzyclust.timeseries.false_nearest_neighbors(y, u=None, max_na=4, max_nb=0, R_tol=15.0, A_tol=2.0, scale=True, delay=1)[source]#

Classical false-nearest-neighbor percentages over the model orders \((n_a, n_b)\).

For every regression vector \(\mathbf{x}_k=[y_{k-1},\dots,y_{k-n_a},u_{k-1},\dots,u_{k-n_b}]^T\) the nearest neighbor \(\mathbf{x}_j\) in the regression space is found. If the regressors carry enough information the outputs of neighbors are close too; following Kennel, Brown & Abarbanel the neighbor is declared false when

\[\frac{|y_k-y_j|}{\|\mathbf{x}_k-\mathbf{x}_j\|} > R_{tol} \qquad\text{or}\qquad \frac{\sqrt{\|\mathbf{x}_k-\mathbf{x}_j\|^2+(y_k-y_j)^2}}{R_A} > A_{tol},\]

where \(R_A\) is the standard deviation of the output (the size of the attractor). The percentage of false neighbors is tabulated over the orders; it drops to (nearly) zero once the regression vector is complete. With u=None this is the original embedding-dimension test for a scalar time series (the new coordinate being \(y_k\)), with inputs it is the input–output extension of Rhodes & Morari.

Parameters:
yarray_like of shape (T,)
uarray_like of shape (T,), optional
max_na, max_nbint

Largest numbers of lagged outputs and inputs considered.

R_tolfloat, default=15.0

Threshold of the slope criterion (Kennel: 10–50).

A_tolfloat, default=2.0

Threshold of the attractor-size criterion.

scalebool, default=True

Standardize regressors and output before measuring distances (strongly recommended for input–output data of different units).

delayint, default=1

Lag \(\tau\) of the delay embedding for a scalar time series (u=None): the regressors are \(y_{k-\tau},\dots,y_{k-n_a\tau}\).

Returns:
tablepandas.DataFrame

Percentage of false nearest neighbors; rows \(n_a\), columns \(n_b\) (a single column 0 for a time series). The entry \((0,0)\) is 100 by definition.

References

[1]

M. B. Kennel, R. Brown, H. D. I. Abarbanel, “Determining embedding dimension for phase-space reconstruction using a geometrical construction”, Physical Review A 45 (1992) 3403–3411.

[2]

C. Rhodes, M. Morari, “Determining the model order of nonlinear input/output systems”, AIChE Journal 44 (1998) 151–163.

Examples

>>> import numpy as np
>>> from fuzzyclust.timeseries import false_nearest_neighbors
>>> rng = np.random.RandomState(0); y = np.zeros(400)
>>> for k in range(2, 400): y[k] = 0.6 * y[k-1] - 0.3 * y[k-2] + 0.1 * rng.randn()
>>> table = false_nearest_neighbors(y, max_na=4)
>>> bool(table.loc[2, 0] < table.loc[1, 0])
True

Examples using fuzzyclust.timeseries.false_nearest_neighbors#

Model-order selection by false nearest neighbors with a cluster-based threshold

Model-order selection by false nearest neighbors with a cluster-based threshold

State-space reconstruction and prediction of a chaotic time series

State-space reconstruction and prediction of a chaotic time series