Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truncated negative autocorealation #123

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/traditional_de/estimate_delay.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ function estimate_delay(x::AbstractVector, method::String,
return mincrossing(c, τs)
elseif method=="exp_decay"
c = autocor(x, τs; demean=true)
if any(x -> x ≤ 0, c)
error("The correlation function has elements that are ≤ 0. "*
"We can't fit an exponential to it. Please choose another method.")
end
τ = exponential_decay_fit(τs, c)
idx = length(c)
idx = findfirst(<(0), c)
τ = exponential_decay_fit(τs[:idx], c[:idx])
Comment on lines +55 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here idx is the first index that c is negative. So by doing c[1:idx] you will for sure include the negative value. You need to do c[1:idx-1]. Also, please explicitly always include starting index, this [:idx] is python syntax.

return round(Int,τ)
elseif method=="exp_extrema"
c = autocor(x, τs; demean=true)
Expand Down