RQA_functions#

Features#

binscalc()#

binscalc(X, n, d, method)[source]#

Function to calculate number of bins in a multidimensional histogram using a generalised Freedman–Diaconis rule.

Parameters:
  • x (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

Returns:

Bins (array) – number of bins along each dimension

References

  • Freedman, David, and Persi Diaconis. “On the histogram as a density estimator: L 2 theory.” Zeitschrift für Wahrscheinlichkeitstheorie und verwandte Gebiete 57.4 (1981): 453-476.

  • Birgé, Lucien, and Yves Rozenholc. “How many bins should be put in a regular histogram.” ESAIM: Probability and Statistics 10 (2006): 24-45.

mutualinfo()#

mutualinfo(X, Y, n, d)[source]#

Function to calculate mutual information between to time series

Parameters:
  • x (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • y (ndarray) – double array of shape (n,d). second time series

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

Returns:

MI (double) – mutual information between time series

References

  • Shannon, Claude Elwood. “A mathematical theory of communication.” The Bell system technical journal 27.3 (1948): 379-423.

timedelayMI()#

timedelayMI(u, n, d, tau)[source]#

Function to calculate mutual information between a time series and a delayed version of itself

Parameters:
  • u (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

  • tau (int) – amount of delay

Returns:

MI (double) – mutual information between u and u delayed by tau

References

  • Shannon, Claude Elwood. “A mathematical theory of communication.” The Bell system technical journal 27.3 (1948): 379-423.

findtau()#

findtau(u, n, d, grp)[source]#

Function to calculate correct delay for estimating embedding dimension based on the first minima of the tau vs mutual information curve

Parameters:
  • u (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

Returns:

tau (double) – optimal amount of delay for which mutual information reaches its first minima(and global minima, in case first minima doesn’t exist)

delayseries()#

delayseries(u, n, d, tau, m)[source]#

Function to calculate correct delay for estimating embedding dimension based on the first minima of the tau vs mutual information curve

Parameters:
  • u (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

  • tau (int) – amount of delay

  • m (int) – number of embedding dimensions

Returns:

s (ndarray) – 3D matrix ov size ((n-(m-1)*tau,m,d)), time delayed embedded signal

References

  • Takens, F. (1981). Dynamical systems and turbulence. Warwick, 1980, 366–381.

nearest()#

nearest(s, n, d, tau, m)[source]#

Function that would give a nearest neighbour map, the output array(nn) stores indices of nearest neighbours for index values of each observations

Parameters:
  • s (ndarray) – 3D matrix ov size ((n-(m-1)*tau,m,d)), time delayed embedded signal

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

  • tau (int) – amount of delay

  • m (int) – number of embedding dimensions

Returns:

nn (array) – an array denoting index of nearest neighbour for each observation

References

  • Takens, F. (1981). Dynamical systems and turbulence. Warwick, 1980, 366–381.

fnnratio()#

fnnratio(u, n, d, m, tau, r, sig)[source]#

Function that calculates the ratio of false nearest neighbours

Parameters:
  • u (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

  • tau (int) – amount of delay

  • m (int) – number of embedding dimensions

  • r (double) – ratio parameter

  • sig (double) – standard deviation of the data

Returns:

FNN (double) – ratio of false nearest neighbours, for a given embedding dimension m, when compared an embedding dimension m+1

References

  • Kennel, M. B., Brown, R., & Abarbanel, H. D. (1992). Determining embedding dimension for phase-space reconstruction using a geometrical construction. Physical review A, 45 (6), 3403.

fnnhitszero()#

fnnhitszero(u, n, d, m, tau, sig, delta, Rmin, Rmax, rdiv)[source]#

Function that finds the value of r at which the FNN ratio can be effectively considered as zero

Parameters:
  • u (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

  • tau (int) – amount of delay

  • m (int) – number of embedding dimensions

  • r (double) – ratio parameter

  • sig (double) – standard deviation of the data

  • delta (double) – the tolerance value(the maximum difference from zero) for a value of FNN ratio to be effectively considered to be zero

  • Rmin (double) – minimum value of r from where we would start the parameter search

  • Rmax (double) – maximum value of r for defining the upper limit of parameter search

  • rdiv (Int) – number of divisions between Rmin and Rmax for parameter search

Returns:

r (double) – value of r at which the value of FNN ratio effectively hits zero

References

  • Kantz, H., & Schreiber, T. (2004). Nonlinear time series analysis (Vol. 7). Cambridge university press. section 3.3.1

findm()#

findm(u, n, d, tau, sd, delta, Rmin, Rmax, rdiv, bound)[source]#

Function that finds the value of m whre the r at which FNN ratio hits zero vs m curve flattens(defined by bound value)

Parameters:
  • u (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

  • tau (int) – amount of delay

  • m (int) – number of embedding dimensions

  • r (double) – ratio parameter

  • sig (double) – standard deviation of the data

  • delta (double) – the tolerance value(the maximum difference from zero) for a value of FNN ratio to be effectively considered to be zero

  • Rmin (double) – minimum value of r from where we would start the parameter search

  • Rmax (double) – maximum value of r for defining the upper limit of parameter search

  • rdiv (Int) – number of divisions between Rmin and Rmax for parameter search

  • bound (double) – bound value for terminating the parameter serch

Returns:

m (double) – value of embedding dimension

References

  • Kantz, H., & Schreiber, T. (2004). Nonlinear time series analysis (Vol. 7). Cambridge university press. section 3.3.1

reccplot()#

reccplot(u, n, d, m, tau, eps)[source]#

Function that computes the recurrence plot

Parameters:
  • u (ndarray) – double array of shape (n,d). Think of it as n points in a d dimensional space

  • n (int) – number of samples or observations in the time series

  • d (int) – number of measurements or dimensions of the data

  • tau (int) – amount of delay

  • m (int) – number of embedding dimensions

  • eps (double) – radius of the neighbourhood for computing recurrence

Returns:

rplot (ndarray) – recurrence plot

References

  • Eckmann, J.-P., Kamphorst, S. O., Ruelle, D., et al. (1995). Recurrence plots of dynamical systems. World Scientific Series on Nonlinear Science Series A, 16, 441–446.

reccrate()#

reccrate(rplot, n)[source]#

Function that computes the recurrence plot

Parameters:
  • rplot (ndarray) – recurrence plot

  • n (int) – length of RP

Returns:

reccrate (double) – recurrence rate

References

  • Eckmann, J.-P., Kamphorst, S. O., Ruelle, D., et al. (1995). Recurrence plots of dynamical systems. World Scientific Series on Nonlinear Science Series A, 16, 441–446.

findeps()#

findeps(u, n, d, m, tau, reqrr, rr_delta, epsmin, epsmax, epsdiv)[source]#

Function that computes the recurrence plot

Parameters:
  • u (ndarray) – multidimensional time series data

  • n (int) – number of observations

  • d (int) – number of dimensions

  • tau (int) – amount of delay

  • m (int) – embedding dimension

  • reqrr (doubld) – required recurrence rate specified in the input

  • rr_delta (double) – tolerance value for considering a value of recurrence rate to be same as the one that is specified in reqrr

  • epsmin (double) – lower bound for the parameter search for epsilon(neighbourhood radius)

  • epsmax (double) – upper bound for the parameter search for epsilon(neighbourhood radius)

  • epsdiv (double) – number of divisions for the parameter search for epsilon(neighbourhood radius) between epsmin and epsmax

Returns:

eps (double) – epsilon(neighbourhood radius)

References

  • Eckmann, J.-P., Kamphorst, S. O., Ruelle, D., et al. (1995). Recurrence plots of dynamical systems. World Scientific Series on Nonlinear Science Series A, 16, 441–446.

vert_hist()#

vert_hist(M, n)[source]#

Function to compute vertical line distribution(counts of line lengths)

Parameters:
  • m (ndarray) – recurrence plot

  • n (int) – length of RP

Returns:

nvert (array) – an array containing counts of line lengths

References

  • Webber Jr, C. L., & Zbilut, J. P. (1994). Dynamical assessment of physiological systems and states using recurrence plot strategies. Journal of applied physiology, 76 (2), 965–973.

  • Webber Jr, C. L., & Zbilut, J. P. (2005). Recurrence quantification analysis of nonlinear dynamical systems. Tutorials in contemporary nonlinear methods for the behavioral sciences, 94 (2005), 26–94.

  • Marwan, N., Romano, M. C., Thiel, M., & Kurths, J. (2007). Recurrence plots for the analysis of complex systems. Physics reports, 438 (5-6), 237–329.

  • Marwan, N., Schinkel, S., & Kurths, J. (2013). Recurrence plots 25 years later—gaining confidence in dynamical transitions. Europhysics Letters, 101 (2), 20007.

  • Marwan, N., Wessel, N., Meyerfeldt, U., Schirdewan, A., & Kurths, J. (2002). Recurrence- plot-based measures of complexity and their application to heart-rate-variability data. Physical review E, 66 (2), 026702.

onedhist()#

onedhist(M, n)[source]#

diaghist()#

diaghist(M, n)[source]#

Function to compute diagonal line distribution(counts of line lengths)

Parameters:
  • m (ndarray) – recurrence plot

  • n (int) – length of RP

Returns:

nvert (array) – an array containing counts of line lengths

References

  • Webber Jr, C. L., & Zbilut, J. P. (1994). Dynamical assessment of physiological systems and states using recurrence plot strategies. Journal of applied physiology, 76 (2), 965–973.

  • Webber Jr, C. L., & Zbilut, J. P. (2005). Recurrence quantification analysis of nonlinear dynamical systems. Tutorials in contemporary nonlinear methods for the behavioral sciences, 94 (2005), 26–94.

  • Marwan, N., Romano, M. C., Thiel, M., & Kurths, J. (2007). Recurrence plots for the analysis of complex systems. Physics reports, 438 (5-6), 237–329.

  • Marwan, N., Schinkel, S., & Kurths, J. (2013). Recurrence plots 25 years later—gaining confidence in dynamical transitions. Europhysics Letters, 101 (2), 20007.

  • Marwan, N., Wessel, N., Meyerfeldt, U., Schirdewan, A., & Kurths, J. (2002). Recurrence- plot-based measures of complexity and their application to heart-rate-variability data. Physical review E, 66 (2), 026702.

percentmorethan()#

percentmorethan(hst, mini, n)[source]#

Function to compute determinism and laminarity from the histogram distribution of lines

The idea is to see what fraction of rcurrent points are part of a linear structure, which can be either vertical or horizontal. The definition of a linear structure on an RP is based on the minimum length(mini) given as an input

Parameters:
  • hst (array) – histogram counts of line lengths

  • mini (int) – minimum length of consecutive occurances of value 1 in the RP(either vertically or horizontally) that is considered as a line

  • n (int) – length of RP

Returns:

nvert (array) – an array containing counts of line lengths

References

  • Webber Jr, C. L., & Zbilut, J. P. (1994). Dynamical assessment of physiological systems and states using recurrence plot strategies. Journal of applied physiology, 76 (2), 965–973.

  • Webber Jr, C. L., & Zbilut, J. P. (2005). Recurrence quantification analysis of nonlinear dynamical systems. Tutorials in contemporary nonlinear methods for the behavioral sciences, 94 (2005), 26–94.

  • Marwan, N., Romano, M. C., Thiel, M., & Kurths, J. (2007). Recurrence plots for the analysis of complex systems. Physics reports, 438 (5-6), 237–329.

  • Marwan, N., Schinkel, S., & Kurths, J. (2013). Recurrence plots 25 years later—gaining confidence in dynamical transitions. Europhysics Letters, 101 (2), 20007.

  • Marwan, N., Wessel, N., Meyerfeldt, U., Schirdewan, A., & Kurths, J. (2002). Recurrence- plot-based measures of complexity and their application to heart-rate-variability data. Physical review E, 66 (2), 026702.

mode()#

mode(hst, mini, n)[source]#

Function to find mode of the line distributions

Parameters:
  • hst (array) – histogram counts of line lengths

  • mini (int) – minimum length of consecutive occurances of value 1 in the RP(either vertically or horizontally) that is considered as a line

  • n (int) – length of RP

Returns:

p (int) – mode of line length distribution

References

  • Webber Jr, C. L., & Zbilut, J. P. (1994). Dynamical assessment of physiological systems and states using recurrence plot strategies. Journal of applied physiology, 76 (2), 965–973.

  • Webber Jr, C. L., & Zbilut, J. P. (2005). Recurrence quantification analysis of nonlinear dynamical systems. Tutorials in contemporary nonlinear methods for the behavioral sciences, 94 (2005), 26–94.

  • Marwan, N., Romano, M. C., Thiel, M., & Kurths, J. (2007). Recurrence plots for the analysis of complex systems. Physics reports, 438 (5-6), 237–329.

  • Marwan, N., Schinkel, S., & Kurths, J. (2013). Recurrence plots 25 years later—gaining confidence in dynamical transitions. Europhysics Letters, 101 (2), 20007.

  • Marwan, N., Wessel, N., Meyerfeldt, U., Schirdewan, A., & Kurths, J. (2002). Recurrence- plot-based measures of complexity and their application to heart-rate-variability data. Physical review E, 66 (2), 026702.

maxi()#

maxi(hst, mini, n)[source]#

maximum value in the line length distribution

Parameters:
  • hst (array) – histogram counts of line lengths

  • mini (int) – minimum length of consecutive occurances of value 1 in the RP(either vertically or horizontally) that is considered as a line

  • n (int) – length of RP

Returns:

plmax (int) – max of line length distribution

References

  • Webber Jr, C. L., & Zbilut, J. P. (1994). Dynamical assessment of physiological systems and states using recurrence plot strategies. Journal of applied physiology, 76 (2), 965–973.

  • Webber Jr, C. L., & Zbilut, J. P. (2005). Recurrence quantification analysis of nonlinear dynamical systems. Tutorials in contemporary nonlinear methods for the behavioral sciences, 94 (2005), 26–94.

  • Marwan, N., Romano, M. C., Thiel, M., & Kurths, J. (2007). Recurrence plots for the analysis of complex systems. Physics reports, 438 (5-6), 237–329.

  • Marwan, N., Schinkel, S., & Kurths, J. (2013). Recurrence plots 25 years later—gaining confidence in dynamical transitions. Europhysics Letters, 101 (2), 20007.

  • Marwan, N., Wessel, N., Meyerfeldt, U., Schirdewan, A., & Kurths, J. (2002). Recurrence- plot-based measures of complexity and their application to heart-rate-variability data. Physical review E, 66 (2), 026702.

average()#

average(hst, mini, n)[source]#

Function to find mean of the line distributions

Parameters:
  • hst (array) – histogram counts of line lengths

  • mini (int) – minimum length of consecutive occurances of value 1 in the RP(either vertically or horizontally) that is considered as a line

  • n (int) – length of RP

Returns:

mu (double) – mean of line length distribution

References

  • Webber Jr, C. L., & Zbilut, J. P. (1994). Dynamical assessment of physiological systems and states using recurrence plot strategies. Journal of applied physiology, 76 (2), 965–973.

  • Webber Jr, C. L., & Zbilut, J. P. (2005). Recurrence quantification analysis of nonlinear dynamical systems. Tutorials in contemporary nonlinear methods for the behavioral sciences, 94 (2005), 26–94.

  • Marwan, N., Romano, M. C., Thiel, M., & Kurths, J. (2007). Recurrence plots for the analysis of complex systems. Physics reports, 438 (5-6), 237–329.

  • Marwan, N., Schinkel, S., & Kurths, J. (2013). Recurrence plots 25 years later—gaining confidence in dynamical transitions. Europhysics Letters, 101 (2), 20007.

  • Marwan, N., Wessel, N., Meyerfeldt, U., Schirdewan, A., & Kurths, J. (2002). Recurrence- plot-based measures of complexity and their application to heart-rate-variability data. Physical review E, 66 (2), 026702.

entropy()#

entropy(hst, mini, n)[source]#

Function to find entropy of the line distributions

Parameters:
  • hst (array) – histogram counts of line lengths

  • mini (int) – minimum length of consecutive occurances of value 1 in the RP(either vertically or horizontally) that is considered as a line

  • n (int) – length of RP

Returns:

ent (int) – entropy of line length distribution

References

  • Webber Jr, C. L., & Zbilut, J. P. (1994). Dynamical assessment of physiological systems and states using recurrence plot strategies. Journal of applied physiology, 76 (2), 965–973.

  • Webber Jr, C. L., & Zbilut, J. P. (2005). Recurrence quantification analysis of nonlinear dynamical systems. Tutorials in contemporary nonlinear methods for the behavioral sciences, 94 (2005), 26–94.

  • Marwan, N., Romano, M. C., Thiel, M., & Kurths, J. (2007). Recurrence plots for the analysis of complex systems. Physics reports, 438 (5-6), 237–329.

  • Marwan, N., Schinkel, S., & Kurths, J. (2013). Recurrence plots 25 years later—gaining confidence in dynamical transitions. Europhysics Letters, 101 (2), 20007.

  • Marwan, N., Wessel, N., Meyerfeldt, U., Schirdewan, A., & Kurths, J. (2002). Recurrence- plot-based measures of complexity and their application to heart-rate-variability data. Physical review E, 66 (2), 026702.