Finding local maxima from interpolated function

In summary, the conversation discusses the need to interpolate data and find local maximas on a given domain. The person is struggling to do so and is using a code to illustrate their position. They also mention using the FindMaximum function and adjusting the step size to find missing maximas.
  • #1
member 428835
Hi PF!

I have data that I need to interpolate (don't want to go into details, but I HAVE to interpolate it). I'm trying to find the local maximas on a given domain. I've looked everywhere and still haven't been able to do it? Seems most people work with NDSolve, but I don't use that function.

Below is a simple code that illustrates my position. I'm trying to find the local maxima of ##f##.

data = Transpose[{Table[i, {i, 1, 30}], RandomReal[{0, 1}, {1, 30}] // Flatten}];
ListLinePlot[data]
f = Interpolation[data];
Plot[{f[x]}, {x, 1, 10}]
 
Physics news on Phys.org
  • #2
Try
Code:
maxima = Table[FindMaximum[f[x], {x, i}], {i, 1, 9, .1}]
DeleteDuplicates[maxima,
Function[{a, b}, (Abs[a[[2, 1, 2]] - b[[2, 1, 2]]] < 0.1)]]

If you find that you are missing some maxima then you can always decrease the step size for your starting point.
 
Last edited:
  • Like
Likes member 428835
  • #3
Thanks so much!
 

1. What is the definition of a local maximum?

A local maximum is a point on a function where the value of the function is greater than the values of the function at all neighboring points. In other words, it is the highest point within a small interval around that point.

2. Why is it important to find local maxima in an interpolated function?

Finding local maxima in an interpolated function can help us identify the highest points on the function, which can be useful for optimization problems or for understanding the shape and behavior of the function.

3. How do you find local maxima from an interpolated function?

To find local maxima from an interpolated function, you can use the first and second derivatives of the function. A local maximum will occur when the first derivative is equal to 0 and the second derivative is less than 0.

4. Can there be more than one local maximum in an interpolated function?

Yes, it is possible for an interpolated function to have multiple local maxima. This can occur when the function has multiple peaks or when there are points where the first derivative is equal to 0 and the second derivative changes sign.

5. Is finding local maxima from an interpolated function a deterministic process?

No, finding local maxima from an interpolated function is not a deterministic process. It depends on the accuracy of the interpolation method used and the density of data points. Different interpolation methods may give slightly different results, and small changes in the input data can also affect the location of local maxima.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
902
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
269
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
228
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
Replies
1
Views
959
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
5
Views
553
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
878
  • Calculus and Beyond Homework Help
Replies
2
Views
332
Back
Top