Algorithmica

, Volume 60, Issue 1, pp 95–109

# Fitting a Step Function to a Point Set

Article

## Abstract

We consider the problem of fitting a step function to a set of points. More precisely, given an integer k and a set P of n points in the plane, our goal is to find a step function f with k steps that minimizes the maximum vertical distance between f and all the points in P. We first give an optimal Θ(nlog n) algorithm for the general case. In the special case where the points in P are given in sorted order according to their x-coordinates, we give an optimal Θ(n) time algorithm. Then, we show how to solve the weighted version of this problem in time O(nlog 4 n). Finally, we give an O(nh 2log n) algorithm for the case where h outliers are allowed. The running time of all our algorithms is independent of k.

## Keywords

Algorithm Design Optimization Computational geometry Shape fitting Histogram

## Preview

Unable to display preview. Download preview PDF.

## References

1. 1.
Agarwal, P., Har-Peled, S., Yu, H.: Robust shape fitting via peeling and grating coresets. In: Proceedings of the 17th Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 182–191 (2006) Google Scholar
2. 2.
Agarwal, P., Sharir, M.: Efficient algorithms for geometric optimization. Comput. Surv. 30 (1998) Google Scholar
3. 3.
Aggarwal, A., Schieber, B., Tokuyama, T.: Finding a minimum-weight k-link path in graphs with the concave Monge property and applications. Discrete Comput. Geom. 12, 263–280 (1994)
4. 4.
Atanassov, R., Bose, P., Couture, M., Maheshwari, A., Morin, P., Paquette, M., Smid, M., Wuhrer, S.: Algorithms for optimal outlier removal. J. Discrete Algorithms 2(7), 239–248 (2009)
5. 5.
Ben-Or, M.: Lower bounds for algebraic computation trees. In: Proceedings of the 15th Annual ACM Symposium on Theory of Computing, pp. 80–86 (1983) Google Scholar
6. 6.
Bender, M., Farach-Colton, M.: The LCA problem revisited. In: Proceedings of the LATIN 2000: Theoretical Informatics, 4th Latin American Symposium, pp. 88–94 (2000) Google Scholar
7. 7.
Buragohain, C., Shrivastava, N., Suri, S.: Space efficient streaming algorithms for the maximum error histogram. In: Proceedings of the 23rd International Conference on Data Engineering, pp. 1026–1035 (2007) Google Scholar
8. 8.
Bürgisser, P., Clausen, M., Shokrollahi, M.: Algebraic Complexity Theory. Springer, Berlin (1997)
9. 9.
Frederickson, G.: Optimal algorithms for tree partitioning. In: Proceedings of the 2nd Annual ACM-SIAM Symposium on Discrete Algorithms, pp. 168–177 (1991) Google Scholar
10. 10.
Frederickson, G., Johnson, D.: Generalized selection and ranking: Sorted matrices. SIAM J. Comput. 13(1), 14–30 (1984)
11. 11.
Gabow, H., Bentley, J., Tarjan, R.: Scaling and related techniques for geometry problems. In: Proceedings of the 16th Annual ACM Symposium on Theory of Computing, pp. 135–143 (1984) Google Scholar
12. 12.
Goodrich, M.: Efficient piecewise-linear function approximation using the uniform metric. Discrete Comput. Geom. 14(4), 445–462 (1995)
13. 13.
Guha, S., Shim, K.: A note on linear time algorithms for maximum error histograms. IEEE Trans. Knowl. Data Eng. 19(7), 993–997 (2007)
14. 14.
Har-Peled, S., Wang, Y.: Shape fitting with outliers. SIAM J. Comput. 33(2), 269–285 (2004)
15. 15.
Harel, D., Tarjan, R.: Fast algorithms for finding nearest common ancestors. SIAM J. Comput. 13(2), 338–355 (1984)
16. 16.
Ioannidis, Y., Poosala, V.: Histogram-based solutions to diverse database estimation problems. IEEE Data Eng. Bull. 18(3), 10–18 (1995) Google Scholar
17. 17.
Karras, P., Sacharidis, D., Mamoulis, N.: Exploiting duality in summarization with deterministic guarantees. In: Proceedings of the 13th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 380–389 (2007) Google Scholar
18. 18.
Lopez, M., Mayster, Y.: Weighted rectilinear approximation of points in the plane. In: Proceedings of the LATIN 2008: Theoretical Informatics, 7th Latin American Symposium. Lecture Notes in Computer Science, vol. 4957, pp. 642–653. Springer, Berlin (2008)
19. 19.
Mayster, Y., Lopez, M.A.: Approximating a set of points by a step function. J. Vis. Commun. Image Represent. 17(6), 1178–1189 (2006)
20. 20.
Díaz-Báñez, J., Mesa, J.: Fitting rectilinear polygonal curves to a set of points in the plane. Eur. J. Oper. Res. 130(1), 214–222 (2001)
21. 21.
Wang, D.: A new algorithm for fitting a rectilinear x-monotone curve to a set of points in the plane. Pattern Recognit. Lett. 23(1–3), 329–334 (2002)