JuliaDynamics / ComplexityMeasures.jl

Estimators for probabilities, entropies, and other complexity measures derived from data in the context of nonlinear dynamics and complex systems
MIT License
48 stars 11 forks source link

Sample entropy is negative with unsigned numbers #334

Open refi64 opened 8 months ago

refi64 commented 8 months ago

Describe the bug If I pass unsigned numbers to complexity_normalized(SampleEntropy), the resulting entropy is negative.

Minimal Working Example

A few examples:

julia> entropy_sample(rand(UInt32,6000))
-0.0020435533500534255

julia> entropy_sample(rand(UInt32,6000), normalize = false)
-0.02297010297324151

vs when using signed ints:

julia> entropy_sample(rand(Int32,6000))
0.022439025318529444

julia> entropy_sample(rand(Int32,6000), normalize = false)
0.3244738161894723

I'm not really an expert here so I'm not sure if the non-normalized entropy can be negative, but I'm quite sure the normalized one shouldn't be negative given that it should be in [0,1]?

Package versions

  [ab4b797d] ComplexityMeasures v2.8.0