Functions

src/nonlinear.c File Reference

#include "nonlinear.h"

Go to the source code of this file.

Functions

double ** eeg_nonlinear_prediction_error (const EEG *eeg, int embedding_dim, int time_lag, int npredict, double epsilon, double **output, OptArgList *optargs)
double tdelay_attractor_size (TimeDelayReconstruction *p)
int tdelay_estimate_dimension_fnn (TimeDelayReconstruction *p, double Rtol, double Atol, int num_dim)
int tdelay_estimate_timelag_autocorr (TimeDelayReconstruction *p)
int tdelay_estimate_timelag_mutual (TimeDelayReconstruction *p, long partitions, long corrlength, double *mutual)
double tdelay_fnn_ratio (TimeDelayReconstruction *p, double Rtol, double Atol)
void tdelay_free (TimeDelayReconstruction *p)
void tdelay_index_i (TimeDelayReconstruction *p, int i, double *x)
double tdelay_index_ij (TimeDelayReconstruction *p, int i, int j)
void tdelay_index_j (TimeDelayReconstruction *p, int j, double *x)
TimeDelayReconstructiontdelay_init (int m, int tau, double *x, int n)
double tdelay_predict_simple (TimeDelayReconstruction *p, double *sample, int npredict, double epsilon)
 simple nonlinear predicition.
void tdelay_print (FILE *out, TimeDelayReconstruction *p)
double tdelay_simple_nonlinear_prediction_error (TimeDelayReconstruction *reference, double *y, int yn, int npredict, double epsilon)

Function Documentation

double** eeg_nonlinear_prediction_error ( const EEG eeg,
int  embedding_dim,
int  time_lag,
int  npredict,
double  epsilon,
double **  output,
OptArgList optargs 
)

Calculate a trial x trial matrix M_ij that contains the prediction error when predicting time-series points in trial j using trial i as the reference.

The function uses tdelay_simple_nonlinear_prediction_error() for prediction.

Parameters:
eeg 
embedding_dim embedding dimensionm for phase space reconstruction
time_lag time-lag in sampling units used for phase space reconstruction
npredict prediction for npredict timesteps ahead
epsilon defines the initial neighbourhood (e.g. 1/4 of the variance in the data points)
allocated memory of eeg->ntrials x eeg->ntrials or ALLOC_IN_FCT
optargs may contain:

  • "channel=int" calculate the trial x trial matrix for this channel, default=0
  • "progress=void*" progressbar callback-function; default=NULL
Returns:
the trial x trial matrix contain the prediction errors; NULL if an error occured

Definition at line 175 of file nonlinear.c.

double tdelay_attractor_size ( TimeDelayReconstruction p  ) 

estimate size of the attractor from a scalar time-series using

\[ R = \sqrt{ \frac{1}{N}\sum_{i=1}^{N} (x_i - \langle x\rangle_i)^2 } \]

where

\[ \langle x\rangle_i = \frac{1}{N}\sum_{i=1}^{N} x_i \]

Definition at line 475 of file nonlinear.c.

int tdelay_estimate_dimension_fnn ( TimeDelayReconstruction p,
double  Rtol,
double  Atol,
int  num_dim 
)

Estimate the embedding dimension for the phase-space from the number of false-nearest-neighbours as proposed in

KENNEL et al. DETERMINING EMBEDDING DIMENSION FOR PHASE-SPACE RECONSTRUCTION USING A GEOMETRICAL CONSTRUCTION. Physical Review A (1992) vol. 45 (6) pp. 3403-3411

Parameters:
\xrefitem todo 12.
Returns:

Definition at line 364 of file nonlinear.c.

int tdelay_estimate_timelag_autocorr ( TimeDelayReconstruction p  ) 

estimate time-lag based on the first zero of the autorcorrelation function.

Definition at line 331 of file nonlinear.c.

int tdelay_estimate_timelag_mutual ( TimeDelayReconstruction p,
long  partitions,
long  corrlength,
double *  mutual 
)

estimate time-lag based on the first local minimum of the mutual information.

This function is "inspired" (stolen and adapted) from TISEAN 3.1, http://www.mpipks-dresden.mpg.de/~tisean

Ref: R. Hegger, H. Kantz, and T. Schreiber, Practical implementation of nonlinear time series methods: The TISEAN package, CHAOS 9, 413 (1999)

Parameters:
p the phase-space rep of the signal
partitions number of partitions to use (if <0, 16 is used as default)
corrlength maximum corrlength (if <0, 20 is used as default)
mutual if != NULL, the array is filled with the mutual information for each time-lag (corrlength-long)
Returns:
the minimum of mutual

Definition at line 246 of file nonlinear.c.

double tdelay_fnn_ratio ( TimeDelayReconstruction p,
double  Rtol,
double  Atol 
)

Estimate number of false-nearest-neighbours as proposed in

KENNEL et al. DETERMINING EMBEDDING DIMENSION FOR PHASE-SPACE RECONSTRUCTION USING A GEOMETRICAL CONSTRUCTION. Physical Review A (1992) vol. 45 (6) pp. 3403-3411

by applying two criteria.

(1) if

\[ \frac{ |x_{i+m\tau} - x^{r}_{i+m\tau} |} {} > R_{tol} \]

then state i is

Definition at line 386 of file nonlinear.c.

void tdelay_free ( TimeDelayReconstruction p  ) 

Definition at line 572 of file nonlinear.c.

void tdelay_index_i ( TimeDelayReconstruction p,
int  i,
double *  x 
)

Get an element from phase-space reconstruction:

\[ \vec{x}_i = \sum_{j=1}^{m}s_{i+(j-1)\tau}\vec{e}_j \]

Parameters:
p is the phase-space rep. of the data
i as in the formula above
x output (m long vector containing the final vector)

Definition at line 523 of file nonlinear.c.

double tdelay_index_ij ( TimeDelayReconstruction p,
int  i,
int  j 
)

Get an element from phase-space reconstruction:

\[ \vec{x}_i = \sum_{j=1}^{m}s_{i+(j-1)\tau}\vec{e}_j \]

Parameters:
p is the phase-space rep. of the data
i,j as in the formula above

Definition at line 500 of file nonlinear.c.

void tdelay_index_j ( TimeDelayReconstruction p,
int  j,
double *  x 
)

Get a dimension from phase-space reconstruction:

\[ \vec{x}_i = \sum_{j=1}^{m}s_{i+(j-1)\tau}\vec{e}_j \]

Parameters:
p is the phase-space rep. of the data
j as in the formula above
x output (n long vector containing the final vector)

Definition at line 546 of file nonlinear.c.

TimeDelayReconstruction* tdelay_init ( int  m,
int  tau,
double *  x,
int  n 
)

Definition at line 562 of file nonlinear.c.

double tdelay_predict_simple ( TimeDelayReconstruction p,
double *  sample,
int  npredict,
double  epsilon 
)

simple nonlinear predicition.

Using the Simple-Prediction algorithm from

Kantz & Schreiber 1997 Nonlinear Time-Series Analysis. Cambridge University Press

this function calculates the current+npredict's sample of the time series from which sample has been taken based on the time-series in p. It's basically an average over all points that are npredict time-steps after those points in p that are closer to sample than epsilon.

It's also described here:

R. Hegger, H. Kantz, and T. Schreiber, Practical implementation of nonlinear time series methods: The TISEAN package, CHAOS 9, 413 (1999)

Parameters:
p prediction time-series
sample predict time-points after this sample (must be of same dimension as p->m)
npredict predict n time-steps
epsilon epsilon-ball placed around all points in p to look for sample
Returns:
the predicted sample in the time-series

Definition at line 93 of file nonlinear.c.

void tdelay_print ( FILE *  out,
TimeDelayReconstruction p 
)

Definition at line 576 of file nonlinear.c.

double tdelay_simple_nonlinear_prediction_error ( TimeDelayReconstruction reference,
double *  y,
int  yn,
int  npredict,
double  epsilon 
)

Calculates the root mean square prediction error averaged over all samples in y. I.e. the function predicts the npredict'th following sample for each point in y and sums up the RMSE for all these predictions. The result is divided by yn.

\[ result = \frac{1}{yn}\sum_{i=1}^{i=yn} RMSE( predict(y,npredict), y[i+npredict] ) \]

with $ RMSE(r,d) = \sqrt{ \frac{1}{\#r} \sum{ (r-d)^2)}} $ For prediction, the function uses tdelay_predict_simple().

Parameters:
reference is the reference signal used for prediction
y signal to predict for
yn length of y
npredict prediction for npredict timesteps ahead
epsilon defines the initial neighbourhood
Returns:
root mean square prediction error cumulated (see above)

Definition at line 138 of file nonlinear.c.