Fractal metrics

Module for computing fractal metrics

stmetrics.fractal.dfa_fd(timeseries, nvals=None, overlap=True, order=1, nodata=-9999)

Detrended Fluctuation Analysis (DFA) measures the Hurst parameter H, which is very similar to the Hurst Exponent (HE). The main difference is that DFA can be used for non-stationary time series.

Parameters:
  • timeseries (numpy.ndarray) – Time series.
  • nvals (int) – Sizes of subseries to use.
  • overlap (Boolean) – if True, there will be a 50% overlap on windows otherwise non-overlapping windows will be used.
  • order (Boolean) – Polynomial order of trend to remove.
  • nodata (int) – nodata of the time series. Default is -9999.
Return dfa:

Detrended Fluctuation Analysis.

Note

This function uses the Detrended Fluctuation Analysis (DFA) implementation from the Nolds package. Due to time series characteristcs we use by default the ‘RANSAC’ fitting method as it is more robust to outliers. For more details regarding the hurst implementation, check Nolds documentation page.

stmetrics.fractal.hurst_exp(timeseries, nvals=None, nodata=-9999)

Computes the Hurst Exponent (HE) by a standard rescaled range (R/S) approach. HE is a self-similarity measure that assesses long-range dependence in a time series. It can be used to determine whether the time series is more, less, or equally likely to increase if it has increased in previous steps.

Parameters:
  • timeseries (numpy.ndarray) – Time series.
  • nvals (int) – Sizes of subseries to use.
  • nodata (int) – nodata of the time series. Default is -9999.
Return hurst:

The Hurst Expoent (HE).

Note

This function was adapted from the package Nolds. Due to time series characteristcs we use by default the ‘RANSAC’ fitting method as it is more robust to outliers. For more details regarding the hurst implementation, check Nolds documentation page.

stmetrics.fractal.katz_fd(timeseries, nodata=-9999)

Katz fractal dimension.

It is defined by: .. math:: K = frac{log_{10}(n)}{log_{10}(d/L)+log_{10}(n)} where \(L\) is the total length of the time series and \(d\) is the Euclidean distance between the first point in the series and the point that provides the furthest distance with respect to the first point.

Parameters:
  • timeseries (numpy.ndarray) – Time series.
  • nodata (int) – nodata of the time series. Default is -9999.
Return kfd:

Katz fractal dimension.

Note

This function was adapted from the package entropy available at: https://github.com/raphaelvallat/entropy.

Tip

To know more about it: Michael J. Katz, Fractals and the analysis of waveforms, Computers in Biology and Medicine, volume 18, Issue 3,1988, Pages 145-156,ISSN 0010-4825, https://doi.org/10.1016/0010-4825(88)90041-8. Esteller, R. et al. (2001). A comparison of waveform fractal dimension algorithms. IEEE Transactions on Circuits and Systems I: Fundamental Theory and Applications, 48(2), 177-183. Goh, Cindy, et al. “Comparison of fractal dimension algorithms for the computation of EEG biomarkers for dementia.” 2nd International Conference on Computational Intelligence in Medicine and Healthcare (CIMED2005). 2005.

stmetrics.fractal.ts_fractal(timeseries, funcs=['all'], nodata=-9999)

This function computes 4 fractal dimensions and the hurst exponential.

  • DFA: measures the Hurst parameter H, which is similar to the Hurst exponent.
  • HE: self-similarity measure that assess long-range dependence in a time series.
  • KFD: This algorirhm computes the FD using Katz algorithm.
Parameters:
  • timeseries (numpy.ndarray) – Time series.
  • nodata (int) – nodata of the time series. Default is -9999.
Return out_metrics:
 

Dictionary with fractal metrics values.