Prominence calculator from findpeaks seems off?

8 vues (au cours des 30 derniers jours)
Reinder Dorman
Reinder Dorman le 15 Fév 2021
Commenté : Reinder Dorman le 16 Fév 2021
Hi all,
I'm trying out the findpeaks function to find the most prominent peak. The function documentation (see here) gives a pretty clear explanation of how the prominence is calculator. In short, from the central peak, find the lowest point to the left and right of said peak, and take the distance from the highest of these two untill the peak (someone correct me if I'm wrong here). However, I'm not sure if I'm missing a point or there is something wrong here.
First figure
For the first signal (first figure below), this seems to be in the correct ballpark. Very roughly, I would say this is the distance between the low point (reference point) around -9 (just over x=5000), and the peak (let's say 12), which would give a prominence of about 21. The reported prominence by the function is 27.94. First of all, this doesn't seem to fit entirely with the ballpark estimation, but this was very rough.
Second figure
Now looking at the second figure, the positive peak here is far less prominent. The low, reference point in this case would be about -2.2 or so (almost touching x=0), and the peak seems to be around 3.2 or so. One would guestimate this prominance at about 5.4 or so. However, the findpeaks function gives a prominence of 65.57.
First of all, this doesn't check out with the reference-to-peak rationale I was following, and second, this prominence value is way higher than the value of the first signal, which does not seems to make sense to me.
I'm using the function as follows, where data is always a 1x10000 vector of singles
findpeaks(data,'NPeaks',1,'SortStr','descend');
I think I understand the rationale of the prominence calculation from the function documentation, but I could be wrong. Otherwise I don't really know what's going on here. If anyone can point me in the right direction, that would be great (Or if anyone wants to verify that this function is behaving weird, that's okay too).
(NB. There are many more other peaks that also don't seem to check out in terms of prominence calculators)
  6 commentaires
Just Manuel
Just Manuel le 16 Fév 2021
Modifié(e) : Just Manuel le 16 Fév 2021
well, this looked like some usage issue to me :)
If you look at the docs, there are these 3 signatures for output arguments:
pks = findpeaks(data)
[pks,locs] = findpeaks(data)
[pks,locs,w,p] = findpeaks(data)
so, in order to get the prominence, you need to use the third one like this:
[peak, offset, ~, prominence] = findpeaks(...)
cheers
Manuel
Reinder Dorman
Reinder Dorman le 16 Fév 2021
I knew it. I frikkin knew it. I can hardly express myself now without turning to faul language, so I'll keep my emotion away from this board.
Thanks for this. And it again confirms the old credo "the computer is never wrong, the programmer is".

Connectez-vous pour commenter.

Réponses (0)

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by