TPU ChatChat on IRC
Internet Relay Chat?
Java Applet client
Who's on IRC?
graphing algorithm - finding peak/valley
Posted by p_c_w [send private reply] at May 10, 2002, 11:29:14 AM Hi Does anyone have experience with graphing algorithms.
I need to find out how to find peak/lows of a graph.. Please help or point me in the right direction. Thankts.
Posted by CodeRed [send private reply] at May 10, 2002, 02:32:01 PM Two variables, one the last coord, the other the current. While the last is greater than the current you are going downhill, or while the last is less then the current you are going uphill. When you switch between uphill and downhill you have a peak, when you switch between downhill and uphill you have a valley
Posted by CViper [send private reply] at May 12, 2002, 05:10:11 AM if you got a function f(x) representing your graph, find the first and second derivate (spelling?) of it, eg f'(x) and f''(x).
now everywhere f'(x) == 0, you've got a peak or valley.
if f''(x) > 0, then it's a valley, if < 0 it's a peak.
that is if i remeber all the stuff correctly.. you could always check a mathemtics book :)
Posted by CodeRed [send private reply] at May 12, 2002, 06:20:14 PM Yeah, if you want to find the functions second derivative everytime, my way is faster. Either way you have scan the entire range, my way doesn't ivolve complex math.
Posted by CodeRed [send private reply] at May 12, 2002, 06:22:15 PM Besides, what if it is not a mathematical graph? what if it is a landscape with curves and stuff, if it was a piece-wise function it would be very difficult
Posted by vikram_1982 [send private reply] at May 13, 2002, 10:07:58 AM Code red's method should be easiert implement :)
Posted by CViper [send private reply] at May 13, 2002, 10:52:19 AM well the question isn't too specific about the type of the graph either :)
finding the derviates runtime is a bit hard, but my way is quite easy if you have the function from the beginning. whatever.
Register as a new user