Skip to content

Commit

Permalink
fix incorrectly not propagated option r in sample entropy (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
Datseris authored Apr 7, 2024
1 parent 5484e5a commit ae414e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "ComplexityMeasures"
uuid = "ab4b797d-85ee-42ba-b621-05d793b346a2"
authors = "Kristian Agasøster Haaga <[email protected]>, George Datseries <[email protected]>"
repo = "https://github.com/juliadynamics/ComplexityMeasures.jl.git"
version = "3.4.1"
version = "3.4.2"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
8 changes: 4 additions & 4 deletions src/complexity_measures/sample_entropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/convenience.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ae414e7

Please sign in to comment.