what's the meaning of 'minprominence' in islocalmin or islocalmax function?

63 views (last 30 days)
I'm studying the offical course "Machine Learning Onramp" right now.
In the course, the task 3 in Engineering Features > Finding Peaks told me how to use 'minprominence' in islocalmin or islocalmax function.
In the function, it set 'minprominence' to 0.1. Is that means to select a point that it's value is larger or smaller over 0.1 than the points on the both side of this point? If my understanding is correct, please someone told me why matlab select these three points as the right answer in the online course?
(the value of the points that matlab select is in blue, the value of the points on it's both sides is in red)

Accepted Answer

Turlough Hughes
Turlough Hughes on 25 Sep 2022
Given that I don't have your dataset, I'll use the following data to help demonstrate how prominence is calculated:
x = 0:0.01:6*pi;
f = @(x) 0.5.*x + sin(x);
y = f(x);
figure(), plot(x,y)
So, we have three equally prominent local minima (and maxima for that matter). We can determine the local minima for this data and show their prominences using islocalmin() as follows:
[idxmin,P] = islocalmin(y);
figure(), plot(x,y)
hold on, plot(x(idxmin),y(idxmin),'or')
disp(P(idxmin)) % display the prominences of local minima
0.6848 0.6848 0.6848
And we get a value of 0.6848 for each local minimum, and this makes sense because the local minima do indeed appear to be equally prominent... but where does the value 0.6848 come from?
islocalmin documentation tells us the following on prominence:
"To measure the prominence of a valley, first extend a horizontal line from the valley. Find where the line intersects the data on the left and on the right, which will either be another valley or the end of the data. Mark these locations as the outer endpoints of the left and right intervals. Next, find the highest peak in both the left and right intervals. Take the smaller of these two peaks and measure the vertical distance from that peak to the valley. This distance is the prominence."
I don't know about you, but I had to read that more than once. Anyway, for the sample data that I provided at the start of this answer, you can see that the interval for the first local minimum is roughly 0.9 to 18.8 and the highest peaks on each side of the local minimum by the following graph:
% Replot previous graph
figure(), plot(x,y)
iMin = find(idxmin);
hold on, plot(x(iMin(1)),y(iMin(1)),'or')
% Shows the horizontal line
iMin = find(idxmin);
% Also the highest peaks on the left and right of the current local minimum
iMax = find(islocalmax(y));
hold on, plot(x(iMax([1 3])),y(iMax([1 3])),'sr','MarkerFaceColor','red')
islocalmin considers the highest peak on the left and right side and uses the smaller of the two - We get the prominence by subtracting the local minimum from the smaller peak.
In other words, the y value for the red square on the left minus the y value for the open circle.
y(iMax(1)) - y(iMin(1))
ans = 0.6848
  1 Comment
on 25 Sep 2022
Thank you for the answer! I've went through all your code, now I fully understand the meaning of it. appreciate:)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by