STATUS: unstable Functions using nonlinear systems-theory. More...
#include "mathadd.h"
#include "distances.h"
#include "definitions.h"
Go to the source code of this file.
Data Structures | |
struct | TimeDelayReconstruction |
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 (double Rtol, int m_start, int m_end) |
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) |
TimeDelayReconstruction * | tdelay_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) |
Array * | tdelay_to_array (TimeDelayReconstruction *p) |
STATUS: unstable Functions using nonlinear systems-theory.
In general, the phase space is represented through a two-dimensional DOUBLE-array (a matrix). This can e.g. be all electrodes over time or any tranformation of the raw data.
Time-Delay reconstruction is done as in
where is a multiple of the sampling step.
There is a special structure for time-delay reconstruction to avoid the space-overhead. This structure saves only the 1D original time-series and calculates the other dimensions on the fly.
The disadvantage of this approach is that there need to be special functions to deal with these structs. Some of the functions are implemented both for general phase-spaces (full matrices) and the TimeDelayReconstruction struct. Others are not. You can always convert from a TimeDelayReconstruction-struct to a Matrix using tdelay_to_array()
double *data=getdata(100); TimeDelayReconstruction *p=tdelay_init( 4, 10, data, 100 ); Array *space=tdelay_to_array( p );
Functions that are designed to be used with the TimeDelayReconstruction begin with the prefix tdelay_*.
Handling of the struct is done via
TimeDelayReconstruction* tdelay_init ( int m, int tau, double *x, int n ); void tdelay_free ( TimeDelayReconstruction *p ); void tdelay_print( FILE *out, TimeDelayReconstruction *p);
and it can be indexed with
double tdelay_index_ij( TimeDelayReconstruction *p, int i, int j ); void tdelay_index_i ( TimeDelayReconstruction *p, int i, double *x); void tdelay_index_j ( TimeDelayReconstruction *p, int j, double *x);
Definition in file nonlinear.h.
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.
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:
|
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
where
Definition at line 475 of file nonlinear.c.
int tdelay_estimate_dimension | ( | double | Rtol, | |
int | m_start, | |||
int | m_end | |||
) |
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)
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) |
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
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:
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:
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:
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)
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 |
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.
with For prediction, the function uses tdelay_predict_simple().
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 |
Definition at line 138 of file nonlinear.c.
Array* tdelay_to_array | ( | TimeDelayReconstruction * | p | ) |