Skip to content

About

Complexity measures for 1D sequences (Higuchi FD, Lempel-Ziv, compression, Lyapunov)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

complexeva

complexeva logo

Fast, low-memory complexity measures for 1D time series (EEG, MEG, physiology).

complexeva-intro.phone.mp4

Also on YouTube, with chapters.

pip install complexeva  # Python 3.14+
import numpy
import complexeva

signal = numpy.random.randn(1000)   # one signal, shape (time,)
complexeva.hfd(signal)              # one float

batches

Pass every signal at once with time on the last axis; you get one value per signal, in the shape of the other axes. Each value is identical to calling the measure on that signal alone.

eeg = numpy.random.randn(64, 1000)              # (channels, time)
complexeva.hfd(eeg)                             # shape (64,)

study = numpy.random.randn(20, 64, 1000)        # (subjects, channels, time)
complexeva.sample_entropy(study)                # shape (20, 64)

recording = numpy.random.randn(1000, 64)        # time first? put time last
complexeva.dfa(recording.T)                     # shape (64,)

windows = numpy.lib.stride_tricks.sliding_window_view(signal, 200)[::10]  # (windows, 200), no copy
complexeva.permutation_entropy(windows)         # one value per window

Some measures take one signal only; see batches.

surrogate tests

result = complexeva.surrogate_test(complexeva.hfd, signal, n=99, seed=0)
print(result.observed, result.surrogate_mean, result.delta, result.pvalue)

optional GPU backend

pip install 'complexeva[gpu]'
from complexeva import gpu

gpu.hfd(eeg)  # one Higuchi fractal dimension per signal
gpu.spectrum_shuffle_test(eeg, n_shuffles=39, seed=0)  # PyTorch surrogates, CPU entropy
Read more Topics
CPU surrogate tests Surrogate methods, options and p-values
GPU backend Device selection, precision and shuffle test

measures

measure input paper
sample entropy
sample_entropy
(…, time) Richman & Moorman 2000
cited by
approximate entropy
approximate_entropy
(…, time) Pincus 1991
cited by
correlation dimension
correlation_dimension
(…, time) Grassberger & Procaccia 1983
cited by
detrended fluctuation analysis
dfa
(…, time) Peng 1994
cited by
permutation entropy
permutation_entropy
(…, time) Bandt & Pompe 2002
cited by
largest Lyapunov exponent
lyapunov_exponent
1D Rosenstein 1993
cited by
multiscale entropy
multiscale_entropy
(…, time) Costa 2002
cited by
Wu 2013 (method="modified")
cited by
Higuchi fractal dimension
hfd, hfd_hilbert
(…, time) Higuchi 1988
cited by
Varley 2020
cited by
Hjorth mobility and complexity
hjorth
(…, time) Hjorth 1970
cited by
compression complexity
compression_complexity
1D Cilibrasi & Vitányi 2005
cited by
fuzzy entropy
fuzzy_entropy
(…, time) Chen 2007
cited by
Katz fractal dimension
katz_fd
(…, time) Katz 1988
cited by
Lempel–Ziv complexity
lempel_ziv, lempel_ziv_hilbert
(…, time) Kaspar & Schuster 1987
cited by
Schartner 2017
cited by
spectral entropy
spectral_entropy
(…, time) Inouye 1991
cited by
Petrosian fractal dimension
petrosian_fd
(…, time) Petrosian 1995
cited by
SVD entropy
svd_entropy
(…, time) Roberts 1999
cited by

speed and memory vs other packages

Ratio of each other package's time and peak heap to complexeva's, per measure at N = 1k, 10k and 100k; above 1 favours complexeva.

Batches, against a loop of the best other package (NUMBA_NUM_THREADS sets the thread count):

Ratio of the best other package loop's time and peak heap to complexeva's batch call for each measure at three shapes, with 16 threads; above 1 favours complexeva.

validation

Higuchi fractal dimension follows the theoretical fBm dimension from 1.9 to 1.1 as the Hurst exponent increases.

Normalized Lempel–Ziv complexity is low for a sine wave and near one for white noise, with signal excerpts alongside.

licence

MIT

Video credits

About

Complexity measures for 1D sequences (Higuchi FD, Lempel-Ziv, compression, Lyapunov)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages