Abstract
Polynomial approximation problems represent a class of specially structured problems which are frequently encountered in empirical curve-fitting. Two generators for creating such problems have been developed, implemented and used in the testing of discrete L1 approximation codes. Both generators permit automatic generation of problems with specified characteristics and (for one generator) having known, unique and controllable solutions.
Keywords: Algorithm testing, approximation, computational experiment, least absolute deviation, polynomial approximation, test problems
1. Introduction
Recent years have seen increased interest in least absolute deviation (L1) data fitting, either as an alternative to or in conjunction with the usual least squares approach [11, 19].1 Estimation in the L1 norm has certain desirable statistical properties (such as “robustness” [14, 16] when the underlying error distribution is long-tailed) and it can be carried out using reasonably efficient mathematical programming procedures.
While a number of algorithms for discrete L1 approximation have recently been advanced [1, 3, 5, 6, 21, 22], computational comparisons of specific implementations (“codes”) for these approaches have not only been limited [3, 6, 22) but have often produced conflicting evidence. Resolution of these conflicts awaits the establishment of reliable and comprehensive methodology for testing such mathematical software.
As a first step in developing a sound evaluation methodology for comparing mathematical programming codes, four L1 codes (representing a range of solution techniques and implementation strategies) were evaluated on particular classes of test problems [13]. The first group of test problems were “hand-picked” problems [20] – those created with a specified structure in mind or arising from actual applications. The second group consisted of pseudo-randomly generated problems, produced by means of a test problem generator [17] and representative of a range of general L1 data fitting problems; such problems could be constructed with a number of controllable characteristics such as degeneracy, rank loss and optimal solution.
The two generators POLY1 and POLY2 described in this paper have subsequently been utilized to produce other types of problem classes for which L1 approximation is appropriate. In particular, these are problems in which it is desired to obtain the best L1 polynomial approximation to a specific function (POLY1) or to a set of discrete observations (POLY2). Polynomial approximation problems are frequently encountered in practice (e.g., among our hand-picked problems), and also enjoy an extensive theoretical basis [7, 18, 23]. Moreover, such problems are known to admit a range of “ill-conditioning” and numerical difficulties [10], notably evidenced in our previous testing efforts using 27 hand-picked problems [13] and in recent results obtained using the first of these two generators [8].
The use of generated test problems in code evaluation offers several advantages. Generators provide a virtually inexhaustible source of test problems, and a source that can be made relatively transportable from one computer to another. Since generators are able to provide test problems with controllable characteristics (such as size and structure), fairly well-defined classes of problems can be efficiently created. Moreover, through the invocation of pseudo-random number generators, test problems can be “randomly” selected from such problem classes and valid statistical conclusions can be drawn about code performance with respect to these classes. Another desirable property of test problem generators, and one that is useful in judging the accuracy or correctness of a code, involves the ability to specify in advance the solution to a generated problem.
Two generators are presented here for obtaining polynomial approximation test problems for L1 curve-fitting. Both generators permit automatic generation of test problems with stipulated characteristics, and one of them (POLY2) allows the specification of known and unique solutions to the generated problems. The theoretical design of both generators is discussed in section 2, and the following two sections describe computer implementations of the theoretical design. The Appendices contain FORTRAN listings for both generators, written to be machine-independent.2
2. Design of the Generators
The discrete linear L1 approximation problem can be formulated as follows. Given a set of n observations on a single dependent variable y and each of m + 1 independent variables z0, …, zm, find parameters β0, …, βmthat minimize
The L1 polynomial approximation problem, with which we will be concerned, is a restricted case of the above formulation: namely, minimize by choice of β = (β0, …, βm)
In the above, yi refers to the i-th observation on variable y and xi refers to the i-th observation on (the single independent) variable x. Equivalently, it is required to find a polynomial of degree m which best fits the given data, in the sense of minimizing the sum of absolute values of the residuals
A vector β* which yields the minimum value ϕ* of ϕ(β) is termed a solution vector, with optimum objective function value ϕ*. Unlike the case of L1 polynomial approximation over a continuous interval [23, p. 38], the optimum solution vector β* to a discrete L1 polynomial approximation problem need not be unique. It is known [2, 4, 12] that such a solution vector can always be found which interpolates at least m + 1 of the data points; that is, at least m + 1 residuals ei are identically zero at the solution. A given problem exhibits degeneracy if more than m + 1 residuals equal zero at the optimum.
A number of algorithms for solving discrete L1 approximation problems make essential use of the above “interpolation” or “extreme point” result. Namely, these algorithms examine only basic solutions, where precisely m + 1 residuals are zero, and move in a systematic way from one basic solution to another. Any such basic solution is defined by a set of m + 1 indices (or rows) i ϵ {1, 2, …, n} where ei = 0. For convenience, these indices are said to correspond to active constraints, while the remaining indices correspond to inactive constraints. Thus, in the absence of degeneracy the set N = {l, 2, …, n} can for any basic solution be partitioned as N = N0 ∪ N+ ∪ N−, where N0 indicates the active constraints, N+ the inactive constraints with positive residuals, and N− the inactive constraints with negative residuals.
The two generators for polynomial approximation problems discussed here will, for specified n and m, produce the following test problem data:
| (1) |
3 and
| (2) |
The basic difference between the generators resides in the type of problem structure they simulate.
The first generator, POLY1, is intended to model the situation where one wishes to approximate, over a discrete set, a continuous function f(x) by a polynomial of specified degree. Accordingly, the values yi, in (2) are given by yi, = f(xi). Controllable features of this generator include: the function f(x), the real interval I over which f(x) is to be approximated, the number and distribution of observation points xi ϵ I, and the degree m of the approximating polynomial. A more detailed description of this generator is provided in section 3. It should be noted that POLY1 does not produce a known solution to the test problem created; therefore, other means are necessary in order to verify whether or not a given L1 code has actually “solved” a generated problem. For this reason, we have also devised a computer routine to check optimality of codeproduced solutions by examination of the Kuhn-Tucker conditions for an associated linear program [4, 17].
The second generator, POLY2, models the situation where an L1 fit is required to a given discrete set of data (yi, xi), i = 1, …, n. Unlike the case for POLY1, the yi are not assumed to be generated via some known functional relation. Controllable features of this second generator include: the real interval of approximation I, the number and distribution of observation points xi ϵ I, the degree of the approximating polynomial, and the statistical distribution of the residuals ei Moreover, one is also able to specify in advance a solution vector β* which will be guaranteed to be the unique L1 solution to the generated problem.
The approach used for generating a data set (X, y) with known optimal solution β* will now be outlined. The matrix X in (1) is partitioned as
corresponding to indices i ϵ N0, N+, and N− respectively. Note that X0 is a square (m + 1) × (m + 1) nonsingular matrix, with the proviso that the xi’s for i ϵN0 are distinct. By a result proved in [17], a sufficient condition for the optimality and uniqueness of β* in (X, y) is that
| (3) |
and that
| (4a) |
where
| (4b) |
It will now be shown how values xi can be found that satisfy (3).
First, we note that for j = 0, equation (3) requires ∣N+∣ = ∣N −∣. For notational convenience, let r = ∣N+∣ = ∣N−∣ and redefine the xi’s (i ϵ N+) as v1, …, vr; similarly, let the xi’s (i ϵ N−) be denoted as w1 …, w r. Also, write
| (5) |
if
Then, following the development in [15], it is straightforward to verify that for any d
| (6) |
Relation (6) can be used recursively to produce values xi that satisfy (3). For example, since
equation (6) gives
and so forth. Accordingly, the consecutive integers 0, 1, 2, …, 2q+1 — 1 can be divided into two disjoint subsets {v1, …, vr} and {w1, …, wr}, with r = 2q, such that [v1, …, vr]q = [w1, …, wr]q. The first subset consists of all integers l, 0 ≤ l ≤ 2q+1 − 1 wilth an even number of ones in their binary expansion, and the second subset consists of all such integers with an odd number of ones. Dividing each vp and wp by 2q+1 −1 produces a set of numbers equally spaced on [0, 1], which in turn can be scaled and translated to yield a set of numbers equally spaced on an arbitrary interval I = [a, b]. Moreover, relation (5) still holds for the scaled and translated . Finally, these values can be used in (3) as the required xi’s for i ϵN+ and i ϵN−, respectively.
More generally the recursive process based on (6) can be initiated, using any positive integer d0, by means of
and propagated using any d1, d2, …, dq to produce 2q+1 numbers satisfying (5), and therefore (3). We have chosen (see sect. 4) to generate the dj’s from a uniform probability distribution. The resulting (scaled and translated) values for xi are no longer equally-spaced on I, but tend to be approximately normally distributed within the (finite) interval I. With probability one, all such xi values generated are distinct.
The above procedures form the theoretical basis for implementation of the second generator. Either equidistant xi or nonequidistant xi (corresponding to inactive constraints) can thus be generated. To ensure that (3) holds for j = 0, …, m, the number of observations n is required to be of the form
| (7) |
where k is an integer, k ≥ 0. Further details of POLY2 are described in section 4.
3. Computer Implementation of POLY1
This section describes a computerized version, in FORTRAN, for the first generator (POLY1) discussed in section 2. We will indicate those problem design characteristics available as user-specified input options to P0LY1, and then discuss how these inputs are utilized in creating test problem data.
A variety of characteristics are available to the user as controllable options and are specified through input parameters to POLY1. These options include:
The number of observations n.
The degree m of the approximating polynomial.
The specific function f(x) to be approximated. Ten such functions,4 representing a variety of shapes likely to be encountered in practice, have been incorporated within the program (see table 1 and fig. 1).
The interval of approximation I = [a, b].
A switch ICOL to indicate whether the approximating polynomial includes a constant term or not. (The latter case is useful in forcing the approximating polynomial to pass through the origin.)
The location of the n observation points xi within I: either drawn from a uniform probability distribution or equally-spaced over I.
A perturbation factor EPS, possibly zero, used in perturbing equally-spaced observation points xi.
Two initial starting seeds, utilized internally by a pseudo-random number generator.
Table 1.
Functions and Their Intervals of Approximation.
| f(x) | I = [a, b] | |
|---|---|---|
| 1. | e−x sin x | [0, 4] |
| 2. | e x sin x | [0, 4] |
| 3. | ex sin x | [0, 7] |
| 4. | e2x/2x | [.05, 1] |
| 5. | 75x/[l + (7.5x)2] | [0, 2] |
| 6. | 10xe−.5x | [0, 4] |
| 7. | 1/[1 + (x - 2.5)4] | [0, 5] |
| 8. | xlj3 | [−1, 1] |
| 9. | xlj2 | [0, 1] |
| 10. | 1/[1 + x4] | [−2.5, 2.5] |
Figure 1.
Graphs of functions.
Given these input parameters, generation of the data sets can begin. The first step involves selecting the n observation points xi, from the desired interval, according to the distributional form specified. The interval I = [a, b] is determined by the user (if CSWTCH ≠ 0) through input parameters ENDL = a and ENDR = b, or (if CSWTCH = 0) by means of the default interval settings shown in table 1. The observation points are chosen according to a uniform probability distribution over I (if MSWTCH ≠ 0) or equally-spaced over I (if MSWTCH = 0). In the latter case, the user has the ability of perturbing the equally-spaced observation points xi: namely, if I = [a, b] then
where is the common subinterval length for equal spacing, the αi are independent uniform random variates over [−1, 1], and EPS is a user-supplied input representing the (maximum) fraction of the subinterval length Δ used for perturbation. If EPS = 0.0, no perturbation is performed; otherwise, a reasonable range for EPS is 0 < EPS < 1/2.
Next, the values yi — f(xi) are calculated, as well as the successive powers . If the user has specified a constant term in the approximating polynomial (ICOL = 1), then the above index j has range j = 0, 1, …, m. Otherwise (ICOL ≠ 1), a constant term is not included and j = 1, …, m. This stage of calculating successive powers is most sensitive to finite-precision arithmetic and to accumulated round-off error. Accordingly, such quantities are calculated in double-precision, using the recursion .
Finally, the problem data are returned in a single matrix PRBMAT. The first column of PRBMAT contains the vector y, and the remaining columns contain the design matrix X. In addition, the number of rows (NOBS) and the number of columns (NPAR) in matrix PRBMAT are returned to the calling routine, as well as a single-precision vector containing the observation points xi. The final seeds available from the random number generator are also returned in ISEED and JSEED, thus allowing the creation of different test problems (having the same input specifications) in successive calls of POLY1 from a main routine.
All error messages are written out using unit IOUT = 6. Changing this specific value of IOUT once at the beginning of the program permits other print unit numbers to be accommodated. Appendix A gives a complete listing of POLY1, together with the subroutine UNIRAN [9], a well-tested uniform random number generator which it calls.
Figure 2 illustrates the type of test problem that can be created by POLY1. The n = 50 data points (yi, xi) are derived from function 7 of table 1 over I = [0, 5] and are shown here by the symbol “x”; in this case, the xi’s were chosen to be equally-spaced (without perturbation) over I. By way of reference, the solid curve indicates the best L1 fitting polynomial of degree m = 5 to these generated data.
Figure 2.
Sample test problem created by POLY1 for function 7, m = 5, and n = 50.
4. Computer Implementation of POLY2
This section describes a computer implementation of the second generator (POLY2) for polynomial approximation problems. As indicated in section 2, an important feature of this generator is its ability to create data sets whose optimal L1 solution vector can be specified in advance. Consequently, the correctness and accuracy of solutions produced by various L1 codes can be readily assessed using the known solutions to such problems. The fact that these solutions are guaranteed to be unique is also advantageous, since in the case of nonunique solutions it becomes difficult to compare the efficiency and accuracy of codes that reach correct, but different, solutions.
A number of problem characteristics can be controlled by the user through appropriate input specifications. Options available in POLY2 include:
The degree m of the approximating polynomial.
The value k in (7), which together with m determines the number of observations n.
The (unique) solution vector BETA to the generated problem.
The interval of approximation I = [a, b].
The location of the observation points xi corresponding to active constraints: either drawn from a uniform probability distribution or equally-spaced over I.
The location of the observation points xi, corresponding to inactive constraints: either equally-spaced or unequally-spaced over I.
A perturbation factor EPS, possibly zero, used in perturbing equally-spaced xi associated with active constraints.
The distribution of the residuals ei associated with inactive constraints.
Two initial starting seeds, utilized internally by pseudo-random number generators.
The first step in developing a test problem is to select the solution vector BETA, if the user has not chosen to input a vector to POLY2. The solution vector is randomly selected, in this case, from a uniform probability distribution over an interval specified by the user (BSW = 1) or defined within the program (BSW ≠ 1).
Next, the observation points xi are generated from the interval I according to the desired distribution. Interval I is either specified on input (CSW = 1) or assigned a default setting within the program (CSW ≠ 1). The xi’s corresponding to active constraints are derived from a uniform probability distribution over I (MSW = 1) or are equally-spaced over I (MSW ≠ 1). In this latter case, the xi can be perturbed using the factor EPS, exactly as described for POLY1. The observation points xi corresponding to inactive constraints are generated so that equation (3) is satisfied. Such xi are either equally-spaced (ISW = 1) or unequally-spaced (ISW ≠ 1) over the interval I; see section 2 for details of how these two methods of generation are achieved.
Also, the entries of the design matrix are successively calculated for j = 0, …, m using appropriate care to preserve numerical accuracy. At the same time, the residuals ei, i ϵN+ or i ϵN−, are generated from either a uniform (RSW = 1) or a normal distribution (RSW ≠ l), are given the appropriate sign, and are then used to calculate yi from (4a) – (4b). The optimum objective function value SUMRES is calculated in double-precision, based on these residuals. The input parameter RESID indirectly controls the magnitude of this objective function value. Namely, RESID acts as a scale factor with respect to the size of the residuals, which are either selected from a uniform distribution on [– RESID, RESID], whose standard deviation is thus RESID/√3, or from a normal distribution having mean 0 and standard deviation RESID.
Finally, the problem data are returned as before in a single matrix PRBMAT. The first column of PRBMAT contains the y vector, and the remaining columns contain the design matrix X. The number of rows (KKM1) and the number of columns (M2) are also returned, as well as BETA, SUMRES and LOC (a vector containing the m + 1 row locations of the active constraints). The final seeds available from the last call to the random number generator are returned in ISEED and JSEED.
All error messages are written out using unit IOUT, which can be easily modified to accommodate differing print unit assignments. Appendix B gives a complete listing of POLY2, together with the subroutines it calls: SORTM, SET1, SET2, EQUAL, NORRAN, SORTP and UNIRAN. The call structure of these subroutines is shown in figure 3; the latter three subroutines are fairly well-tested and are described further in [9].
Figure 3.
Subroutine call strut lire for POLY2.
Figures 4 and 5 illustrate the types of data sets that can be produced using POLY2. Both show as dots 134 data points (yi, xi) together with the best L1 fitting polynomial of degree 5 (solid curve). In figure 4, the xi are generated via the equally-spaced option (ISW = 1), while in figure 5 they are generated via the unequally-spaced option (ISW ≠ 1).
Figure 4.
Sample test problem created by POLY2: n = 134, m = 5, equally-spaced xi.
Figure 5.
Sample test problem created by POLY2: n = 134, m = 5, unequally-spaced xi.
6. Appendix A. Listing of FORTRAN Subroutines for First Generator:
POLY1
UNIRAN

7. Appendix B. Listing of FORTRAN Subroutines for Second Generator:
POLY2
SET1
SET2
UNIRAN*
NORRAN
EQUAL
SORTM
SORTP
* For a listing of UNIRAN, refer to Appendix A.


Footnotes
AMS Subject Classification: 65D10, 65D15, 68A20
Numbers in brackets indicate literature references at the end of this paper.
All FORTRAN programs have been checked for portability using the PFORT verifier (B. G. Ryder, Software-Practice and Experience, Vol. 4, 1974, 359–377) and conform to a subset of ANSI FORTRAN (X3.9–1966, Amer. Nat. Stand. Inst., New York, 1966).
For the first generator POLY1, one may also specify whether the polynomial has a constant term (j = 0, …, m) or not (j:= 1, …, m).
It will be noted that function 10 is simply a translation of function 7. It has been included as a separate entity to illustrate the effect of “scaling”: namely, the successive powers produce more ill-conditioning when ∣ xi∣ is larger (function 7) than smaller (function 10).
5. References
- [1].Abdelmalek N. N., An efficient method for the discrete linear L1 approximation problem, Mathematics of Computation, Vol. 29, (1975), 844–850. [Google Scholar]
- [2].Appa G. and Smith C., On L1 and Chebyshev estimation, Mathematical Programming, Vol. 5 (1973), 73–87. [Google Scholar]
- [3].Armstrong R. D. and Frome E. L., A comparison of two algorithms for absolute deviation curve fitting, Journal of the American Statistical Association, Vol. 71, No. 354 (1976), 328–330. [Google Scholar]
- [4].Barrodale I. and Roberts F. D. K., An improved algorithm for discrete l1 linear approximation, SIAM Journal on Numerical Analysis, Vol. 10, No. 5 (1973), 839–848. [Google Scholar]
- [5].Barrodale I. and Roberts F. D. K., Solution of an overdetermined system of equations in the l1 norm, Communications of the Association for Computing Machinery, Vol. 17 (1974), 319–320. [Google Scholar]
- [6].Bartels R. H., Conn A. R. and Sinclair J. W., Minimization techniques for piecewise differentiable functions: The l1 solution to an overdetermined linear system, SIAM Journal on Numerical Analysis, Vol. 15, No. 2 (1978), 224–241. [Google Scholar]
- [7].Davis P. J., Interpolation and Approximation, (Blaisdell, New York, 1965). [Google Scholar]
- [8].Domich P. D., Hoffman K. L., Jackson R. H. F., Saunders P. B. and Shier D. R., Evaluation of L1 codes using polynomial approximation problems, unpublished working paper, National Bureau of Standards. [Google Scholar]
- [9].Filliben J. J., DATAPAC: A data analysis package, Proceedings of the Ninth Interface Symposium on Computer Science and Statistics (Boston, MA, April 1–2, 1976), 212–216. [Google Scholar]
- [10].Forsythe G. E., Generation and use of orthogonal polynomials for data-fitting with a digital computer, SIAM Journal, Vol. 5, No. 2 (1957), 74–88. [Google Scholar]
- [11].Gentle J. E., Least absolute values estimation: An introduction, Communications in Statistics, Vol. B6, No. 4 (1977), 313–328. [Google Scholar]
- [12].Gentle J. E., Kennedy W. J. and Sposito V. A., On least absolute values estimation, Communications in Statistics, Vol. A6, No. 9 (1977), 839–845. [Google Scholar]
- [13].Gilsinn J., Hoffman K., Jackson R. H. F., Leyendecker E., Saunders P. and Shier D., Methodology and analysis for comparing discrete linear L1 approximation codes, Communications in Statistics, Vol. B6, No. 4 (1977), 399–413. [Google Scholar]
- [14].Hampel F. R., A general qualitative definition of robustness, Annals of Mathematical Statistics, Vol. 42 (1971), 1887–1896. [Google Scholar]
- [15].Hardy G. H. and Wright E. M., An Introduction to the Theory of Numbers, (Clarendon Press, Oxford, 1954). [Google Scholar]
- [16].Harter H. L., Nonuniqueness of least absolute values regression, Communications in Statistics, Vol. A6, No. 9 (1977), 829–838. [Google Scholar]
- [17].Hoffman K. and Shier D., A test problem generator for discrete linear L1 approximation problems, to appear in Transactions on Mathematical Software.
- [18].Rice J. R., The Approximation of Functions, Vol. I, (Addison-Wesley, Reading, MA, 1964). [Google Scholar]
- [19].Rice J. R. and White J. S., Norms for smoothing and estimation, SIAM Review, Vol. 6, No. 3 (1964), 243–256. [Google Scholar]
- [20].Saunders P. and Shier D., A collection of test problems for discrete linear L1 data fitting, unpublished working paper, National Bureau of Standards. [Google Scholar]
- [21].Schlossmacher E. J., An iterative technique for absolute deviations curve fitting. Journal of the American Statistical Association, Vol. 68, No. 344 (1973), 857–859. [Google Scholar]
- [22].Spyropoulos K., Kiountouzis E. and Young A., Discrete approximation in the L1 norm, Computer Journal, Vol. 16, No. 2 (1973), 180–186. [Google Scholar]
- [23].Timan A. F., Theory of Approximation of Functions of a Real Variable, trans, by Berry J., (MacMillan Co., New York, 1963). [Google Scholar]


























