naginterfaces.library.fit.dim1_​cheb_​arb

naginterfaces.library.fit.dim1_cheb_arb(kplus1, x, y, w)[source]

dim1_cheb_arb computes weighted least squares polynomial approximations to an arbitrary set of data points.

For full information please refer to the NAG Library document for e02ad

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/e02/e02adf.html

Parameters
kplus1int

, where is the maximum degree required.

xfloat, array-like, shape

The values of the independent variable, for .

yfloat, array-like, shape

The values of the dependent variable, for .

wfloat, array-like, shape

The set of weights, , for . For advice on the choice of weights, see the E02 Introduction.

Returns
afloat, ndarray, shape

The coefficients of in the approximating polynomial of degree . contains the coefficient , for , for .

sfloat, ndarray, shape

contains the root-mean-square residual , for , as described in Notes. For the interpretation of the values of the and their use in selecting an appropriate degree, see the E02 Introduction.

Raises
NagValueError
(errno )

On entry, and .

Constraint: .

(errno )

On entry, , and .

Constraint: .

(errno )

On entry, all have the same value: .

(errno )

On entry, and .

Constraint: , where mdist is the number of distinct values.

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

Notes

In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.

dim1_cheb_arb determines least squares polynomial approximations of degrees to the set of data points with weights , for .

The approximation of degree has the property that it minimizes the sum of squares of the weighted residuals , where

and is the value of the polynomial of degree at the th data point.

Each polynomial is represented in Chebyshev series form with normalized argument . This argument lies in the range to and is related to the original variable by the linear transformation

Here and are respectively the largest and smallest values of . The polynomial approximation of degree is represented as

where , for , are the Chebyshev polynomials of the first kind of degree with argument .

For , the function produces the values of , for , together with the value of the root-mean-square residual . In the case the function sets the value of to zero.

The method employed is due to Forsythe (1957) and is based on the generation of a set of polynomials orthogonal with respect to summation over the normalized dataset. The extensions due to Clenshaw (1960) to represent these polynomials as well as the approximating polynomials in their Chebyshev series forms are incorporated. The modifications suggested by Reinsch and Gentleman (see Gentleman (1969)) to the method originally employed by Clenshaw for evaluating the orthogonal polynomials from their Chebyshev series representations are used to give greater numerical stability.

For further details of the algorithm and its use see Cox (1974) and Cox and Hayes (1973).

Subsequent evaluation of the Chebyshev series representations of the polynomial approximations should be carried out using dim1_cheb_eval().

References

Clenshaw, C W, 1960, Curve fitting with a digital computer, Comput. J. (2), 170–173

Cox, M G, 1974, A data-fitting package for the non-specialist user, Software for Numerical Mathematics, (ed D J Evans), Academic Press

Cox, M G and Hayes, J G, 1973, Curve fitting: a guide and suite of algorithms for the non-specialist user, NPL Report NAC26, National Physical Laboratory

Forsythe, G E, 1957, Generation and use of orthogonal polynomials for data fitting with a digital computer, J. Soc. Indust. Appl. Math. (5), 74–88

Gentleman, W M, 1969, An error analysis of Goertzel’s (Watt’s) method for computing Fourier coefficients, Comput. J. (12), 160–165

Hayes, J G (ed.), 1970, Numerical Approximation to Functions and Data, Athlone Press, London