Real-Time Interpolation of Streaming Data
Total Page:16
File Type:pdf, Size:1020Kb
Computer Science • 21(4) 2020 https://doi.org/10.7494/csci.2020.21.4.3932 Roman Dębski REAL-TIME INTERPOLATION OF STREAMING DATA Abstract One of the key elements of the real-time C1-continuous cubic spline interpola- tion of streaming data is an estimator of the first derivative of the interpolated function that is more accurate than those based on finite difference schemas. Two such greedy look-ahead heuristic estimators, based on the calculus of vari- ations (denoted as MinBE and MinAJ2), are formally defined (in closed form), along with the corresponding cubic splines that they generate. They are then comparatively evaluated in a series of numerical experiments involving different types of performance measures. The presented results show that the cubic Her- mite splines generated by heuristic MinAJ2 significantly outperformed those that were based on finite difference schemas in terms of all of the tested per- formance measures (including convergence). The proposed approach is quite general. It can be directly applied to streams of univariate functional data like time-series. Multi-dimensional curves that are defined parametrically (after splitting) can be handled as well. The streaming character of the algorithm means that it can also be useful in processing data sets that are too large to fit in the memory (e.g., edge computing devices, embedded time-series databases). Keywords streaming algorithm, online algorithm, spline interpolation, cubic Hermite spline Citation Computer Science 21(4) 2020: 513–532 Copyright © 2020 Author(s). This is an open access publication, which can be used, distributed and reproduced in any medium according to the Creative Commons CC-BY 4.0 License. 513 514 Roman Dębski 1. Introduction Cubic splines are in widespread use in numerical analysis, statistics, computer graph- ics, computer-aided design (CAD), and many other disciplines of science and engineer- ing. A significant number of their applications are related to interpolation of sets of discrete data. Well-known natural cubic splines (and B-splines) have proven effective in many of these scenarios, yet they are not always applicable. This is often because of their global character – they require the solution of a system of linear equations whose coefficients depend on a whole interpolated data set. However, access to a whole data set is impossible in a number of cases (e.g., streaming data, big data sets). This scenario is becoming increasingly frequent in contemporary systems, as many sources (e.g., sensor networks, scientific data) produce data continuously; often, the data should be processed in an online fashion. Examples include real-time animation (in computer games or scientific simulations), real-time control, and decision support systems. Taking this into account, effective streaming interpolators should be entirely local and operate in an online fashion. A classic example of such a local interpolant is a cubic Hermite spline, which is made up of cubic polynomial segments that are joined together with common slopes at the data points. If the slopes are not given, they must be estimated – usually with the use of finite difference schemas. Since the accuracy of this approximation method may be insufficient in some cases, a more robust method is desirable. The aim of this paper is to introduce such a method as the foundation of the real-time algorithm that constructs C1-continuous cubic splines in an online fashion. The proposed approach is quite general. It can be directly applied to streams of univariate functional data (like time-series). Multi-dimensional curves that are defined parametrically (after splitting) can be handled as well. The streaming character of the algorithm means that it can also be useful in processing data sets that are too large to fit in the memory (e.g., edge computing devices, embedded time-series databases). The main contributions of this paper are the following: • two greedy look-ahead heuristic estimators of the first derivative of the interpo- lated function (Sections 4.1 and 4.2); • a streaming interpolator that maps a stream of data points to a stream of cubic spline segments (using one of these heuristic estimators), which form a C1-con- tinuous interpolant (Section 4.3); • numerical results that demonstrate the effectiveness of the proposed heuristics as well as the algorithm itself (Section 5). The remainder of this paper is organized as follows. In the next section, the problem statement is given. Following this, the proposed solution is described. Then, the solution is evaluated, and the obtained results are presented and discussed. The last two sections contain a related work overview and the conclusions of the study, respectively. Real-time interpolation of streaming data 515 2. Related work There is an extensive amount of literature on interpolating splines1 that covers a num- ber of disciplines of science and engineering. To understand the recent developments in this field, some historical context (given in a number of seminal papers) is helpful. Historical context. The term interpolation2, according to [26], was initially used in the mathematical sense in [35]. Among the first contributors to the topic of interpolation were Newton, Lagrange, Euler, Gauss, Laplace, and Cauchy. Hermite interpolation (finding a polynomial of which also the first few derivatives assume pre-specified values at given points) was first discussed in [19] and then generalized by [5]. A more thorough treatment of the history of interpolation theories and techniques from the earliest times to the present day can be seen in an excellent review paper by [26]. According to [15], the first reference to a spline (a flexible and mechanical strip of wood that is used to draw smooth curves) appears to be [28]. The mathemati- cal equivalent of a mechanical spline is a spline curve. At first, this corresponded to a curve that minimized a specific functional (elastic bending energy); however, spline curves are generally regarded as piece-wise polynomial curves with certain smooth- ness properties these days. This new idea of a spline curve (and a basic kth-order spline curve, nowadays known as a B-spline) was presented in [30]. This seminal work laid the mathematical foundations for spline approximation and interpolation. More information on splines can be found in [7, 21, 31–33], for example. Selected recent developments: computer-aided geometric design. The generaliza- tion of B-splines to nonuniform rational B-splines (NURBS) has become the stan- dard curve form in the CAD/CAM industry [34]. A special case of NURBS is given by rational Bézier curves [16]. The concepts of Bézier curves [3, 17] and Casteljau’s curves [10] are based on the use of control polygons, which involve both points on the curve and the points close to it. Catmull-Rom splines (as local interpolants) and blending functions are described in [9], for instance. Another piece-wise-defined curve scheme (biarc) was proposed in [6]. Biarcs are piece-wise circular arcs pieced together with tangent continuity; hence, these can be thought of as circle splines. More infor- mation about curves in computer-aided geometric design can be found in [15]. Selected recent developments: real-time applications and trajectory optimization. An approximation of a linearly varying curvature by three cubic curve segments (be- tween four points) was described in [27]. The authors named their approach the curvic interpolation. A similar representation of a curve but used in an online algorithm for the generation of minimum time joint trajectories for industrial manipulators was presented in [2]. Their approach, which they named the 3-Cubic (method), gives con- tinuity of acceleration at the junction points by imposing zero acceleration (at the starting and terminating ends of the segment). 1And curve fitting. 2From the Latin interpolare. 516 Roman Dębski Interpolating splines in the context of real-time/online applications were also researched in [8, 14, 18], and [29]. Online trajectory generation methods in robotic systems are described in [22]. An excellent overview of trajectory-planning methods can be seen in [4]. Among other topics, the authors describe many representations of trajectories: elementary ones like polynomial (of different degrees), trigonometric, or exponential as well as their different compositions and multi-point variants (including different splines). An extension of the spline-based representation to a family of trajectories (multi-spline) used in a parallel dynamic programming-based optimization algorithm was proposed in [12]. This can be treated as an extension of the method presented in [11, 13]. Higher-order splines (of a degree of five or seven) are detailed in an interpolation context in [20, 23–25] and in a trajectory optimization context (3-4-5 and 4-5-6-7 interpolation polynomials) in [1]. 3. Problem statement Consider a stream Sp (finite or infinite) of data points P0;P1;:::;Pk;::: that arrive (or are accessed) sequentially and describe an underlying signal F(q), q 2 R. This signal can represent a trajectory or a curve that is defined parametrically in the following way3: F(q) = (F1(q);F2(q);:::;Fn(q)) ; q 2 R (1) In such a case, each data point Pk can take the following form: Pk = (qk;F1(qk);:::;Fn(qk)) (2) where k = 0; 1; 2 ::: , and it is assumed that qk < qk+1 < qk+2 ::: If n > 1, input (1) (n) stream Sp can be split (as a prepossessing step) into n streams, Sp ;:::;Sp , each describing the characteristic of the interpolated trajectory/curve in one dimension (i) (i) (i) (i) (i) (see Figure 1) and defined as Sp = P0 ;P1 ;:::;Pk ;::: , where Pk = (qk;Fi(qk)), i = 1; : : : ; n and k = 0; 1; 2 ::: splitter (1)(1) (1) (1) P0 P1 P2 P3 (2)(2) (2) P(2) P0 P1 P2 3 P3 P4 P5 P6 ... ... (n) (n) (n) (n) P0 P1 P2 P3 Figure 1.