complexeva

complexeva logo

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

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

Batches work for every measure except lyapunov_exponent, compression_complexity, the _hilbert variants and binary-string lempel_ziv, which take one signal. multiscale_entropy adds a last axis of scales, and hjorth returns a (mobility, complexity) pair of arrays. A non-finite sample raises an error naming its full index; a constant signal gives NaN in its place. NUMBA_NUM_THREADS limits the threads.

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