Given: n discrete data points [ti,xi], which should describe a monotonic function (ti = time, xi = data). Some of the points are "outliers", or disobey the monotonic function rule (x{i+1}>=x{i} for increasing, x{i+1}<=x{i} for decreasing).
I am trying to find an algorithm to determine the minimum number of data points I must eliminate to obtain a monotonic function. I also know if it is increasing or decreasing.
I tried with a moving median filter and identify points which are some variance above or under the filtered function, but I cannot identify all points.
What would be the best approach for this problem?
I am using MATLAB, but the solution can surely be generalized.