Skip to content

Sample Entropy not same value #97

Open

Description

@allran

I compared the libraries:antropy, pyentrp, EntropyHub。
For example, calculate Sample Entropy, all not the same value。
Isn't the algorithm the same?

import antropy as ant
entropy1_5 = ant.sample_entropy(X)

from pyentrp import entropy as ent
entropy2_2 = ent.sample_entropy(X, 2)

import EntropyHub as EH
Samp, _, _ = EH.SampEn(X)

Activity

  1. nikdon commented on Aug 12, 2024

    @nikdon
    Owner

    I believe the differences in Sample Entropy values are due to variations in how each library implements the algorithm. You might want to check if the parameters you're passing are consistent across the libraries. There might be some small numerical differences as well.

  2. drkotireddysaripalli commented on Oct 8, 2026

    @drkotireddysaripalli

    These calls select different quantities in the current sources:

    • pyentrp uses sample_length=m+1, returns a vector, and defaults to r=0.1*std(X). Thus sample_entropy(X, 2) does not include the order-2 estimate.
    • Antropy defaults to scalar order 2 and r=0.2*std(X).
    • EntropyHub's guide defines Samp as orders 0 through m; use its order-2 element.

    To compare order 2 with the same explicit radius on the same unmodified X:

    import numpy as np
    r = 0.2 * np.std(X, ddof=0)
    a = ant.sample_entropy(X, order=2, tolerance=r, metric="chebyshev")
    p = ent.sample_entropy(X, 3, tolerance=r)[2]
    s = EH.SampEn(X, m=2, tau=1, r=r, Logx=np.e)[0][2]

    On a 16-point binary fixture, the exact pyentrp and Antropy Python function bodies agreed at 0.693147 after this alignment; independent pair counts were 20 and 10. That was source-isolated execution with Antropy's JIT decorator removed, not installed-package or EntropyHub execution. Pyentrp counts prefixes of complete longest-template windows, so changing sample_length also changes which tail templates participate. Matching settings does not guarantee equality across versions and boundary conventions; your X and installed versions are still needed for any remaining difference.

    Affiliation: Chief Scientist PinnacleAI(R), Pinnacle Blooms Network of Bharath Healthcare P LIMITED, https://www.pinnacleblooms.org/verify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions