Local max/min of Mathematica data sets.

Click For Summary
SUMMARY

This discussion focuses on identifying local maxima and zeros in data sets using Mathematica. The user seeks a method to find local maxima without polynomial fitting, utilizing a custom function to evaluate peaks based on neighboring points. Additionally, a technique is provided for estimating zeros between two points where the response value changes sign, using a linear interpolation approach. The provided code snippets demonstrate how to implement these functions effectively.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of data smoothing techniques
  • Knowledge of local maxima and minima concepts
  • Basic interpolation methods
NEXT STEPS
  • Explore Mathematica's built-in functions for data analysis
  • Learn about advanced data smoothing techniques in Mathematica
  • Investigate numerical methods for root-finding
  • Study the implementation of custom functions in Mathematica for data manipulation
USEFUL FOR

Data analysts, mathematicians, and researchers working with numerical data sets in Mathematica, particularly those interested in peak detection and root-finding techniques.

wil3
Messages
177
Reaction score
1
Is there a way in Mathematica to find the local maxima of a set of points? I have a fairly fine data set, and I can clearly see several peaks in it that I would like to know the numerical value of (as in, the highest point- I don't need a spline approximation or anything too fancy like that). I have already smoothed the set, so I'd rather not fit polynomials if possible.

Additionally, is there a way to find the expected zeros of a set? Let's say that I have two points in order, and somewhere between them the measured response value drops to negative. I know I can find this manually, but there are enough zeroes that I would prefer not to. I am not too picky regarding whether the guessed zero is based on a linear connection between the two points or some sort of exotic polynomial or spline.

Thanks very much.
 
Physics news on Phys.org
Suppose you have
points={{xa,ya},{xb,yb},{xc,yc}...}

peakQ[{{x1_,y1_},{x2_,y2_},{x3_,y3_}}]:=Abs[y1]<Abs[y2]&&Abs[y2]>Abs[y3];
peaks=Map[#[[2]]&,Select[Partition[points,3,1],peakQ[#]&]]

Then

crossQ[{{x1_,y1_},{x2_,y2_}}]:=Sign[y1]!=Sign[y2];
zero[{{x1_,y1_},{x2_,y2_}}]:=x1+(x2-x1)*Abs[y1]/Abs[y2+y1];
zeros=Map[zero[#]&,Select[Partition[points,2,1],crossQ[#]&]]

Test these carefully on sample data to make certain I haven't made any mistakes.

Then study how and why these work so that you can use these methods yourself in the future.
 
Sorry about the delay in replying. That worked perfectly, like your suggestions always do. Thanks very much for your help.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
11K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K