{"id":20929,"library":"antropy","title":"Antropy","description":"AntroPy is a Python library for estimating entropy and complexity of time-series data, including sample entropy, approximate entropy, permutation entropy, spectral entropy, and fractal dimensions (Petrosian, Katz, Higuchi). Current version is 0.2.2, with regular releases on a roughly annual cadence. Requires Python >= 3.10.","status":"active","version":"0.2.2","language":"python","source_language":"en","source_url":"https://github.com/raphaelvallat/antropy","tags":["entropy","complexity","time-series","fractal-dimension","signal-processing","biomedical"],"install":[{"cmd":"pip install antropy","lang":"bash","label":"pip install"}],"dependencies":[{"reason":"Core numerical operations","package":"numpy","optional":false},{"reason":"Signal processing and statistical functions","package":"scipy","optional":false},{"reason":"Used for KDTree in sample entropy","package":"scikit-learn","optional":false},{"reason":"Optional JIT acceleration for sample entropy and LZ complexity","package":"numba","optional":true}],"imports":[{"note":"","wrong":"","symbol":"app_entropy","correct":"from antropy import app_entropy"},{"note":"","wrong":"","symbol":"sample_entropy","correct":"from antropy import sample_entropy"},{"note":"","wrong":"","symbol":"perm_entropy","correct":"from antropy import perm_entropy"},{"note":"","wrong":"","symbol":"spectral_entropy","correct":"from antropy import spectral_entropy"},{"note":"","wrong":"","symbol":"detrended_fluctuation","correct":"from antropy import detrended_fluctuation"},{"note":"","wrong":"","symbol":"katz_fd","correct":"from antropy import katz_fd"},{"note":"","wrong":"","symbol":"petrosian_fd","correct":"from antropy import petrosian_fd"},{"note":"","wrong":"","symbol":"higuchi_fd","correct":"from antropy import higuchi_fd"},{"note":"","wrong":"","symbol":"lz_complexity","correct":"from antropy import lz_complexity"}],"quickstart":{"code":"import numpy as np\nfrom antropy import sample_entropy, perm_entropy, higuchi_fd\n\n# Generate a random time series\nnp.random.seed(42)\nx = np.random.rand(100)\n\n# Sample entropy\nse = sample_entropy(x)\nprint(f\"Sample entropy: {se:.4f}\")\n\n# Permutation entropy with order 3\npe = perm_entropy(x, order=3)\nprint(f\"Permutation entropy: {pe:.4f}\")\n\n# Higuchi fractal dimension\nhfd = higuchi_fd(x)\nprint(f\"Higuchi fractal dimension: {hfd:.4f}\")","lang":"python","description":"Compute sample entropy, permutation entropy, and Higuchi fractal dimension on a random 1D array."},"warnings":[{"fix":"Upgrade Python to 3.10 or newer.","message":"Python 3.9 is no longer supported as of v0.2.0. Minimum required Python version is 3.10.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"For 2D input, access individual row entropies via indexing. For 1D input, behavior unchanged.","message":"Permutation entropy for order 3 and 4 now returns a 1-D array when input is 2-D, one value per row. Previous behavior returned a scalar or raised an error.","severity":"breaking","affected_versions":">=0.2.2"},{"fix":"Explicitly set r parameter or check signal length is sufficient (typically > 10*(m+1) for embedding dimension m).","message":"Sample entropy uses a default tolerance (r) of 0.2 * std(x). For very short or noisy signals, this may be inappropriate and lead to undefined entropy (nan).","severity":"gotcha","affected_versions":"all"},{"fix":"Install 'stochastic' separately if needed: pip install stochastic","message":"The optional dependency 'stochastic' was removed in v0.1.9. Any code using antropy with that package is unaffected, but imports of 'stochastic' directly will fail if not installed separately.","severity":"deprecated","affected_versions":">=0.1.9"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure the 'dim' parameter (often 'm') is an integer >= 2, e.g., m=2.","cause":"Passing a fractional or too small embedding dimension to sample_entropy or app_entropy.","error":"ValueError: md must be an integer >=2"},{"fix":"Set r to a positive float, typically 0.2 * standard deviation of the signal.","cause":"Passing a non-positive tolerance to sample_entropy or app_entropy.","error":"ValueError: tolerance (r) must be positive"},{"fix":"Install compatible numba version: pip install 'numba>=0.57' or ignore if performance is acceptable.","cause":"Numba version incompatibility or missing LLVM. Antropy uses numba for acceleration, but falls back gracefully.","error":"RuntimeError: Numba jit compilation failed. Falling back to pure Python."},{"fix":"Upgrade to latest version: pip install --upgrade antropy","cause":"Older version of antropy (<0.1.5) did not include petrosian_fd, or function was renamed.","error":"AttributeError: module 'antropy' has no attribute 'petrosian_fd'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}