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

peaks for periodic data #49

Closed
anneaux opened this issue Aug 5, 2024 · 1 comment
Closed

peaks for periodic data #49

anneaux opened this issue Aug 5, 2024 · 1 comment

Comments

@anneaux
Copy link

anneaux commented Aug 5, 2024

Hi,

I was wondering if it was possible to include an option to detect peaks in periodic data?
E.g. if I'm having a simple cos(x) curve over an x range of 0 to 2π, then it would be nice if findmaxima() would detect x=0 (or x=2π) as a maxima.
As a workaround I assume one can just shift the data and search for maxima in there?!

( MWE:findmaxima([cos(ϕ) for ϕ in 0:2π]) gives no peaks. )

Cheers 😀

@halleysfifthinc
Copy link
Owner

Hi, thanks for your interest! Peaks may or may not already be able to do what you're looking for, but I'm not entirely sure from your question.

If you're wanting to symbolically detect peaks from functions, that is not something that is within the scope of this package, and that can be accomplished using other Julia packages that are intended for that problem (see e.g. Roots.jl or IntervalRootFinding.jl).

For the specific example you gave (findmaxima([cos(ϕ) for ϕ in 0:2π])), strictly speaking there are no peaks (maxima) in [cos(ϕ) for ϕ in 0:2π]. If you want to consider the bounds of the array as potential peaks, then you would need to add a strict=false keyword arg to your findmaxima call (e.g. findmaxima([cos(ϕ) for ϕ in 0:2π]; strict=false) which would return 2 peaks, one each at the first and last indices). The documentation has more information on the strict keyword. (Check out the dev docs for newly re-written documentation with expanded explanations of concepts.)

Let me know if you still have any issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants