Finding local maxima from interpolated function

  • Context: Mathematica 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Function Local Maxima
Click For Summary
SUMMARY

This discussion focuses on finding local maxima from an interpolated function using Mathematica. The user employs the Interpolation function to create a continuous representation of discrete data points and utilizes FindMaximum to identify local maxima within a specified domain. The provided code demonstrates the process, including the use of DeleteDuplicates to refine the results. A key takeaway is the recommendation to adjust the step size for starting points to ensure all maxima are captured.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of interpolation techniques in data analysis
  • Knowledge of optimization functions, specifically FindMaximum
  • Basic skills in data visualization using ListLinePlot
NEXT STEPS
  • Explore advanced interpolation methods in Mathematica
  • Learn about the use of NDSolve for solving differential equations
  • Investigate alternative optimization techniques for finding maxima
  • Study the impact of step size adjustments on optimization results
USEFUL FOR

This discussion is beneficial for data analysts, mathematicians, and researchers who need to identify local maxima in interpolated datasets using Mathematica.

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   Reactions: 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
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K