pyhctsa.operations.nonlinearity.embed_kernel_pca¶
-
pyhctsa.operations.nonlinearity.embed_kernel_pca(y, tau=
'ac', m=3, max_n=2000)¶ Kernel PCA of a time-delay embedding of the series, compared with linear PCA.
Reconstructs the time series as a time-delay embedding (as in
embed_pca()) and performs kernel principal components analysis on the result using an RBF kernelexp(-d^2 / median(d^2)), withdthe distance between embedded points, then compares the resulting eigenvalue spectrum to that of ordinary (linear) PCA on the same embedded points [1, 2].At any finite kernel bandwidth, kernel PCA’s spectrum is less compact than linear PCA’s in absolute terms (its RBF feature space is far higher-dimensional than the embedding itself), so the kernel-to-linear ratios (
top2_ratio,nto80_ratio,nto50_ratio) are below 1 (top2_ratio) or at least 1 (nto*_ratio) for every series. The ratios tend to be nearer 1 for series on a curved low-dimensional manifold (such as the logistic and Henon maps) than for the linear (Gaussian) process with the same power spectrum; the difference is weaker for flows such as the Lorenz system, and can be absent for a near-linear oscillator. The ratios are not a stand-alone nonlinearity test, however: they also rise with linear autocorrelation (strongly autocorrelated AR(1) processes have higher ratios than white noise), so a smooth linear process can look more ‘nonlinear’ than a chaotic map. Compare against surrogates to isolate nonlinearity.std_ratiodoes not separate nonlinear from linear series consistently.References
- Parameters:¶
- y : array-like¶
The input time series.
- tau : int or str, optional¶
The time delay of the embedding: an integer, or a rule understood by
pyhctsa.utils.get_tau().'ac'is the first zero-crossing of the autocorrelation function,'ac1e'the (floored) first 1/e crossing of the autocorrelation function, and'mi'the smaller of the first minimum of the (Kraskov) automutual information and the 1/e time. Default is'ac'.- m : int, optional¶
The embedding dimension (at least 2). Default is 3.
- max_n : int or 'full', optional¶
The maximum number of embedded points used to form the N x N kernel matrix, whose eigendecomposition costs O(N^3). Longer embeddings are reduced to their first
max_npoints (a memory/time cap, not a convergence point: the spectrum estimate keeps sharpening with more points);'full'disables this, with a warning above 5000 points, where the eigendecomposition becomes slow. Default is 2000.
- Returns:¶
NaN if the embedding fails, there are too few embedded points for a rank-
mdecomposition, the embedded points coincide, or the kernel spectrum is degenerate. Otherwise statistics of the normalized kernel PCA spectrum (the proportion of variance in feature space explained by each kernel principal component, ordered from largest, one per embedded point), with the linear PCA spectrum of the same points (mentries) for comparison:perc_1, …,perc_m: the proportion of variance explained by each of the topmkernel componentsstd,range,min,max: standard deviation, range, minimum and maximum of the topmproportions only (so they are comparable with linear PCA)top2: the proportion of variance explained by the top two kernel componentsnto50,nto60,nto70,nto80,nto90: the number of kernel components needed to explain more than 50%, 60%, 70%, 80% or 90% of the variancefb05,fb02,fb01,fb001: the position of the first kernel component whose proportion of variance is below 0.5, 0.2, 0.1 or 0.01top2_ratio,top2_diff:top2of the kernel PCA over (and minus) that of linear PCAnto80_ratio,nto80_diff:nto80of the kernel PCA over (and minus) that of linear PCAnto50_ratio:nto50of the kernel PCA over that of linear PCAstd_ratio:stdof the kernel PCA over that of linear PCA
- Return type:¶
dict or float