From ae414e78448b60d62f75191dc724f375584721b5 Mon Sep 17 00:00:00 2001 From: George Datseris Date: Sun, 7 Apr 2024 14:08:48 +0100 Subject: [PATCH] fix incorrectly not propagated option `r` in sample entropy (#396) --- Project.toml | 2 +- src/complexity_measures/sample_entropy.jl | 8 ++++---- src/convenience.jl | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Project.toml b/Project.toml index a268af070..f413b1d16 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "ComplexityMeasures" uuid = "ab4b797d-85ee-42ba-b621-05d793b346a2" authors = "Kristian Agasøster Haaga , George Datseries " repo = "https://github.com/juliadynamics/ComplexityMeasures.jl.git" -version = "3.4.1" +version = "3.4.2" [deps] Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" diff --git a/src/complexity_measures/sample_entropy.jl b/src/complexity_measures/sample_entropy.jl index a3d259774..0233e0fd2 100644 --- a/src/complexity_measures/sample_entropy.jl +++ b/src/complexity_measures/sample_entropy.jl @@ -73,10 +73,10 @@ Base.@kwdef struct SampleEntropy{R} <: ComplexityEstimator r > 0 || throw(ArgumentError("r must be > 0. Got r=$(r).")) new{R}(m, τ, r) end - function SampleEntropy(x::AbstractVector; m::Int = 2, τ::Int = 1) - r = 0.2 * Statistics.std(x) - SampleEntropy(m, τ, r) - end +end + +function SampleEntropy(x::AbstractVector; r = 0.2Statistics.std(x), m::Int = 2, τ::Int = 1) + return SampleEntropy(m, τ, r) end # See comment in https://github.com/JuliaDynamics/ComplexityMeasures.jl/pull/71 for why diff --git a/src/convenience.jl b/src/convenience.jl index 5021a8669..b407feff2 100644 --- a/src/convenience.jl +++ b/src/convenience.jl @@ -8,7 +8,7 @@ export entropy_distribution entropy_distribution(x; τ = 1, m = 3, n = 3, base = 2) Compute the distribution entropy [Li2015](@cite) of `x` using embedding dimension `m` -with delay/lag `τ`, using the Chebyshev distance metric, and using an `n`-element +with delay/lag `τ`, using the Chebyshev distance metric, and using an `n`-element equally-spaced binning over the distribution of distances to estimate probabilities. This function is just a convenience call to: @@ -90,8 +90,8 @@ This is just a wrapper for `complexity(SampleEntropy(; r, m, τ, base), x)`. See also: [`SampleEntropy`](@ref), [`complexity`](@ref), [`complexity_normalized`](@ref)). """ -function entropy_sample(x; normalize = true, kwargs...) - c = SampleEntropy(x; kwargs...) +function entropy_sample(x; normalize = true, r = 0.2std(x), kwargs...) + c = SampleEntropy(x; r, kwargs...) if normalize complexity_normalized(c, x) else