Message: 26
Date: Sat, 04 Dec 2010 12:56:05 -0500
From: Bryan McCormick <br...@deepfoo.com>
To: use-livecode@lists.runrev.com
Subject: Finding local minima and maxima of a graph
Message-ID: <4cfa80b5.3090...@deepfoo.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

I have a very large number of graphs to crunch through to find local
minima and maxima. The data is regularly spaced, which eliminated one
problem. I know too that the window value used has to be an adjustable
variable as peak and trough significance may need to be found for a wide
range of time periods within the data set.

I had thought of using a moving average to find a slope of zero and then
use an offset function to find the peak and trough in time.

I've used stackoverflow to have a look and apparently the problem is a
lot less trivial than I thought.

Any suggestions for fitting to a function, using the graphing functions
in rev, etc would be most welcome.




Bryan,

If the data is "well behaved" you might try just finding out where the derivative (slope) changes sign. For example:

function MinMax tList
   put line 1 of tList into yOld
   put 0 into dyOld
   repeat for each line yNew in tList
      put yNew - yOld into dy
      put dy * dyOld into tChange
      if tChange  < 0 or tChange = 0 then
         put yNew & cr after tExreema
      end if
      put ynew into yOld
      put dy into dyOld
   end repeat
   return tExreema
end MinMax


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to