Mathematica Finding local maxima from interpolated function

Click For Summary
The discussion focuses on the challenge of finding local maxima from interpolated data without using NDSolve. The user provides a code snippet that generates random data, creates an interpolation function, and attempts to identify local maxima using FindMaximum. The suggestion is made to decrease the step size in the starting points for better accuracy in detecting maxima, addressing potential issues with missing maxima in the results. The conversation emphasizes the need for effective interpolation techniques and the importance of fine-tuning parameters to achieve desired outcomes in data analysis.
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
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
Thanks so much!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K