python - Find top 10 values above Y threshold and spread across X -
quick question
i have series of data points defined in 2 lists x , y. i'm looking efficient algorithm select (let's say) 10 values x , y not above particular value of y (a threshold), spread across values of x as possible. 'spread', mean maximising delta between x adjacent points.
for example:
if y threshold = 100 , x range = 1-10, ideal set of values be.
[1,104] [2.5,120] [3,101] [4.7,150] [5.2,190] [6.3,115] etc
a non-ideal set be:
[1,104] [1.3,157] [1.6,174] [1.5,120] [1.17,135] etc
any thoughts appreciated
first extract data points such y > threshold
.
then sort on increasing x
. xmin
, xmax
, compute 8 additional values of x
equally spaced in range, form increasing list z
(the "ideal" values).
now scan both lists in parallel, in merge operation. every time move in z
list, keep corresponding x
element.
caution: process can fail if algorithm finds same x
corresponding 2 different z
's. fixing isn't obvious.
Comments
Post a Comment