min max of a list

querypk at gmail.com querypk at gmail.com
Wed May 4 18:24:36 EDT 2005


If this is the list.

values = [  0,  72,   0,   4,   9,   2,   0,   0,  42,  26,   0, 282,
23,   0, 101, 0,   0,   0,   0,   0]

as we can see there are peaks in the list.that is 0,72,0 is a
group(triangle) with peak 72.then 0,   4,   9,   2,   0,   0 with peak
9 and 0,  42,  26,   0 with 42 and so on...
what I want is the left and right bound index of each bin(triangle).The
list could as big as possible.So some heurestic algorithm which could
first find max in the list and look for local maxima and minima and
group its adjcent bounds.Then find next max and group the bins and so
on.

so that we can get

[[0,2],[2,7],[7,10],[10,13]]
( indexes of the bounds in the values list). so first group [0,2]
correspond to 0,72,0 in the values list and so on...
Hope I am clear.




More information about the Python-list mailing list