Skill Tracer
Skills › Scientific Agent Skills › neurokit2 › complexity.md

complexity.md

212 lines · skills/neurokit2/references/complexity.md at 5f2bc03

Open on GitHub
1# Complexity, entropy, fractals, and RQA
2
3Checked **2026-10-01** against NeuroKit2 0.2.13 stable runtime/source,
4the official Complexity API, and the NeuroKit2 complexity comparison paper.
5

Complexity, entropy, fractals, and RQA

Checked 2026-10-01 against NeuroKit2 0.2.13 stable runtime/source, the official Complexity API, and the NeuroKit2 complexity comparison paper.

Raw lines 1 to 5
6## Return convention changed from older examples
7
8Most stable 0.2.13 complexity functions return:
9
10```python
11value, info = function(signal, ...)
12```
14Examples:
16```python
17sampen, sampen_info = nk.entropy_sample(
18 signal, delay=1, dimension=2, tolerance="sd"
20dfa, dfa_info = nk.fractal_dfa(signal)
21hfd, hfd_info = nk.fractal_higuchi(signal, k_max=10)
22lyapunov, lyapunov_info = nk.complexity_lyapunov(signal)
23fi, fi_info = nk.fisher_information(signal)
24```
26Do not treat the tuple as a scalar. The current public name is
27`fisher_information()`; `information_fisher()` is not exported.
29Exceptions exist: for example, `mutual_information()` returns a float. Check the
30stable signature and persist runtime type/schema.

Return convention changed from older examples

Most stable 0.2.13 complexity functions return:

value, info = function(signal, ...)

Examples:

sampen, sampen_info = nk.entropy_sample(
    signal, delay=1, dimension=2, tolerance="sd"
)
dfa, dfa_info = nk.fractal_dfa(signal)
hfd, hfd_info = nk.fractal_higuchi(signal, k_max=10)
lyapunov, lyapunov_info = nk.complexity_lyapunov(signal)
fi, fi_info = nk.fisher_information(signal)

Do not treat the tuple as a scalar. The current public name is fisher_information(); information_fisher() is not exported.

Exceptions exist: for example, mutual_information() returns a float. Check the stable signature and persist runtime type/schema.

Raw lines 6 to 31
32## `complexity()` is a selected panel
34```python
35features, details = nk.complexity(
36 signal,
37 which="makowski2022",
38 delay=1,
39 dimension=2,
40 tolerance="sd",
42```
44The default does not compute “all complexity measures.” The pinned 0.2.13 probe
45returned a one-row DataFrame with 15 columns:
47```text
48AttEn, BubbEn, CWPEn, Hjorth, LL,
49MFDFA_Asymmetry, MFDFA_Delta, MFDFA_Fluctuation,
50MFDFA_Increment, MFDFA_Max, MFDFA_Mean,
51MFDFA_Peak, MFDFA_Width, MSPEn, SVDEn
52```
54The accompanying dict had method-specific details. This panel reflects a published
55empirical comparison and implementation choices; it is not a universal optimum for
56every signal, endpoint, or population.

complexity() is a selected panel

features, details = nk.complexity(
    signal,
    which="makowski2022",
    delay=1,
    dimension=2,
    tolerance="sd",
)

The default does not compute “all complexity measures.” The pinned 0.2.13 probe returned a one-row DataFrame with 15 columns:

AttEn, BubbEn, CWPEn, Hjorth, LL,
MFDFA_Asymmetry, MFDFA_Delta, MFDFA_Fluctuation,
MFDFA_Increment, MFDFA_Max, MFDFA_Mean,
MFDFA_Peak, MFDFA_Width, MSPEn, SVDEn

The accompanying dict had method-specific details. This panel reflects a published empirical comparison and implementation choices; it is not a universal optimum for every signal, endpoint, or population.

Raw lines 32 to 57
58## Parameter selection
60Phase-space/entropy estimates depend on:
62- delay (`tau`);
63- embedding dimension (`m`);
64- tolerance/radius (`r`);
65- scale/coarse-graining;
66- symbolization/binning;
67- detrending/integration/order;
68- sampling rate and bandwidth; and
69- usable length and stationarity.
71Stable utilities also return metadata:
73```python
74delay, delay_info = nk.complexity_delay(
75 signal, delay_max=100, method="fraser1986", show=False
77dimension, dimension_info = nk.complexity_dimension(
78 signal, delay=delay, dimension_max=10, method="afnn", show=False
80tolerance, tolerance_info = nk.complexity_tolerance(
81 signal,
82 method="maxApEn",
83 delay=delay,
84 dimension=dimension,
85 show=False,
87```
89Optimization can return no solution or raise when search bounds are inadequate. Do not
90silently replace failure with an arbitrary default. Predefine the algorithm/search
91range, report failures, and test sensitivity.
93`tolerance="sd"` commonly maps to a fraction of standard deviation, but amplitude
94normalization, outliers, and signal length alter it. One conventional parameter set is
95not method validation.

Parameter selection

Phase-space/entropy estimates depend on:

  • delay (tau);
  • embedding dimension (m);
  • tolerance/radius (r);
  • scale/coarse-graining;
  • symbolization/binning;
  • detrending/integration/order;
  • sampling rate and bandwidth; and
  • usable length and stationarity.

Stable utilities also return metadata:

delay, delay_info = nk.complexity_delay(
    signal, delay_max=100, method="fraser1986", show=False
)
dimension, dimension_info = nk.complexity_dimension(
    signal, delay=delay, dimension_max=10, method="afnn", show=False
)
tolerance, tolerance_info = nk.complexity_tolerance(
    signal,
    method="maxApEn",
    delay=delay,
    dimension=dimension,
    show=False,
)

Optimization can return no solution or raise when search bounds are inadequate. Do not silently replace failure with an arbitrary default. Predefine the algorithm/search range, report failures, and test sensitivity.

tolerance="sd" commonly maps to a fraction of standard deviation, but amplitude normalization, outliers, and signal length alter it. One conventional parameter set is not method validation.

Raw lines 58 to 96
97## Major stable families

Major stable families

Raw lines 97 to 98
99### Entropy
101Available functions include approximate, sample, fuzzy, permutation, spectral,
102multiscale, dispersion, symbolic-dynamic, SVD, Shannon, Rényi, Tsallis, and other
103variants.
105Pinned probes confirmed `(value, info)` for:
107- `entropy_approximate()`;
108- `entropy_sample()`;
109- `entropy_multiscale()`;
110- `entropy_permutation()`; and
111- `entropy_spectral()`.
113Some values are corrected/normalized by default (for example corrected permutation
114entropy). Record every parameter and logarithm base. Entropy values from different
115algorithms/normalizations are not interchangeable.

Entropy

Available functions include approximate, sample, fuzzy, permutation, spectral, multiscale, dispersion, symbolic-dynamic, SVD, Shannon, Rényi, Tsallis, and other variants.

Pinned probes confirmed (value, info) for:

  • entropy_approximate();
  • entropy_sample();
  • entropy_multiscale();
  • entropy_permutation(); and
  • entropy_spectral().

Some values are corrected/normalized by default (for example corrected permutation entropy). Record every parameter and logarithm base. Entropy values from different algorithms/normalizations are not interchangeable.

Raw lines 99 to 116
117### Fractals
119Stable functions include Katz, Higuchi, Petrosian, Sevcik, NLD, PSD slope, Hurst,
120correlation dimension, DFA/MFDFA, density, line length, and tMF.
122`fractal_dfa()` returns `(float, info)` for monofractal mode and can return a
123DataFrame-like multifractal summary. Report scales, overlap, integration, detrending
124order, q values, and fit diagnostics. Do not interpret alpha values without checking
125which regime and preprocessing generated them.

Fractals

Stable functions include Katz, Higuchi, Petrosian, Sevcik, NLD, PSD slope, Hurst, correlation dimension, DFA/MFDFA, density, line length, and tMF.

fractal_dfa() returns (float, info) for monofractal mode and can return a DataFrame-like multifractal summary. Report scales, overlap, integration, detrending order, q values, and fit diagnostics. Do not interpret alpha values without checking which regime and preprocessing generated them.

Raw lines 117 to 126
127### Lyapunov and RQA
129```python
130lle, lle_info = nk.complexity_lyapunov(
131 signal,
132 delay=1,
133 dimension=2,
134 method="rosenstein1993",
135 separation="auto",
137rqa, rqa_info = nk.complexity_rqa(
138 signal,
139 dimension=3,
140 delay=1,
141 tolerance="sd",
142 method="python",
144```
146The pinned RQA DataFrame had fields such as `RecurrenceRate`, `Determinism`,
147`Laminarity`, `TrappingTime`, line-length/entropy, divergence, and vertical/white-line
148statistics. `rqa_info` included full recurrence and distance matrices, which scale
149quadratically in signal length. Bound input length and memory.
151A positive estimated Lyapunov exponent does not by itself prove deterministic chaos.
152RQA results depend strongly on embedding, tolerance, norm, Theiler window, line
153thresholds, nonstationarity, and sample size.

Lyapunov and RQA

lle, lle_info = nk.complexity_lyapunov(
    signal,
    delay=1,
    dimension=2,
    method="rosenstein1993",
    separation="auto",
)
rqa, rqa_info = nk.complexity_rqa(
    signal,
    dimension=3,
    delay=1,
    tolerance="sd",
    method="python",
)

The pinned RQA DataFrame had fields such as RecurrenceRate, Determinism, Laminarity, TrappingTime, line-length/entropy, divergence, and vertical/white-line statistics. rqa_info included full recurrence and distance matrices, which scale quadratically in signal length. Bound input length and memory.

A positive estimated Lyapunov exponent does not by itself prove deterministic chaos. RQA results depend strongly on embedding, tolerance, norm, Theiler window, line thresholds, nonstationarity, and sample size.

Raw lines 127 to 154
155## Signal preparation
1571. Preserve raw signal and physical unit.
1582. Apply modality-specific artifact/missing-data policy first.
1593. Define the analysis window and usable length.
1604. Decide detrending, filtering, resampling, and standardization before viewing group
161 effects.
1625. Check stationarity or segment according to the estimand.
1636. Compute prespecified measures and diagnostics.
1647. Compare with surrogates/nulls and parameter sensitivity.
166Do not apply blanket z-scoring: amplitude-sensitive measures may change, while scale
167invariant measures may not. Report both rationale and implementation.

Signal preparation

  1. Preserve raw signal and physical unit.
  2. Apply modality-specific artifact/missing-data policy first.
  3. Define the analysis window and usable length.
  4. Decide detrending, filtering, resampling, and standardization before viewing group effects.
  5. Check stationarity or segment according to the estimand.
  6. Compute prespecified measures and diagnostics.
  7. Compare with surrogates/nulls and parameter sensitivity.

Do not apply blanket z-scoring: amplitude-sensitive measures may change, while scale invariant measures may not. Report both rationale and implementation.

Raw lines 155 to 168
169## Length and comparability
171There is no universal minimum sample count across complexity measures. Required length
172grows with embedding dimension, delay, scale count, tolerance, and estimator. Multiscale
173entropy loses points at each coarse-graining scale; RQA and correlation dimension can
174be computationally and statistically unstable on short data.
176- Use equal-duration/beat-count windows for direct comparisons unless a validated
177 correction is used.
178- Quantify estimate reliability with simulation/resampling.
179- Avoid comparing measures computed at different sample rates or bandwidths without
180 explicit validation.
181- Return missing/unsupported rather than a numerically convenient but invalid value.

Length and comparability

There is no universal minimum sample count across complexity measures. Required length grows with embedding dimension, delay, scale count, tolerance, and estimator. Multiscale entropy loses points at each coarse-graining scale; RQA and correlation dimension can be computationally and statistically unstable on short data.

  • Use equal-duration/beat-count windows for direct comparisons unless a validated correction is used.
  • Quantify estimate reliability with simulation/resampling.
  • Avoid comparing measures computed at different sample rates or bandwidths without explicit validation.
  • Return missing/unsupported rather than a numerically convenient but invalid value.
Raw lines 169 to 182
183## Interpretation
185High entropy can mean noise, not useful complexity. “Healthy complexity,” “complexity
186loss,” consciousness, disease, stress, and aging claims require a prespecified theory,
187validated acquisition/preprocessing, appropriate controls, and independent evidence.
189Do not use these measures for diagnosis, anesthesia/consciousness monitoring, seizure
190detection, prognosis, or medical-device validation based on this toolbox alone.

Interpretation

High entropy can mean noise, not useful complexity. “Healthy complexity,” “complexity loss,” consciousness, disease, stress, and aging claims require a prespecified theory, validated acquisition/preprocessing, appropriate controls, and independent evidence.

Do not use these measures for diagnosis, anesthesia/consciousness monitoring, seizure detection, prognosis, or medical-device validation based on this toolbox alone.

Raw lines 183 to 191
192## Reproducible report
194Record:
196- NeuroKit2 version and function return schema;
197- signal type/unit/rate/bandwidth/window/length;
198- exclusions, interpolation, filtering, detrending, resampling, normalization;
199- algorithm, delay, dimension, tolerance, scales/bins/q/order;
200- optimization method/search space and failures;
201- fit/convergence diagnostics and runtime warnings;
202- surrogate/null and sensitivity results; and
203- multiplicity control and participant-level statistical design.

Reproducible report

Record:

  • NeuroKit2 version and function return schema;
  • signal type/unit/rate/bandwidth/window/length;
  • exclusions, interpolation, filtering, detrending, resampling, normalization;
  • algorithm, delay, dimension, tolerance, scales/bins/q/order;
  • optimization method/search space and failures;
  • fit/convergence diagnostics and runtime warnings;
  • surrogate/null and sensitivity results; and
  • multiplicity control and participant-level statistical design.
Raw lines 192 to 204
205## Sources checked 2026-10-01
207- [Official Complexity API](https://neuropsychology.github.io/NeuroKit/functions/complexity.html)
208- [Stable v0.2.13 complexity source](https://github.com/neuropsychology/NeuroKit/tree/v0.2.13/neurokit2/complexity)
209- [Makowski et al. (2022), empirical comparison using NeuroKit2](https://doi.org/10.3390/e24081036)
210- [Richman & Moorman (2000), sample entropy](https://doi.org/10.1152/ajpheart.2000.278.6.H2039)
211- [Peng et al. (1995), DFA](https://doi.org/10.1063/1.166141)
212- [Costa et al. (2005), multiscale entropy](https://doi.org/10.1103/PhysRevE.71.021906)