next up previous 196
Next: PDA_DPOLVL - Evaluate polynomial and its derivatives as produced by PDA_DPLINT.
Up: User-callable routines
Previous: PDA_DPOLCF - Coefficients of the polynomial fit (including Hermite polynomial fits) produced by PDA_DPLINT.


PDA_DPOLFT - Weighted least-squares polynomial fit.

Origin
SLATEC / CAMSUN
Implementation Status:
The routine and its subsidiaries will now return an error status as supplied by PDA_XERMSG.

      SUBROUTINE PDA_DPOLFT (N, X, Y, W, MAXDEG, NDEG, EPS, R, IERR, A,
     +   STATUS)


***BEGIN PROLOGUE  PDA_DPOLFT
***PURPOSE  Fit discrete data in a least squares sense by polynomials
            in one variable.
***LIBRARY   SLATEC
***CATEGORY  K1A1A2
***TYPE      DOUBLE PRECISION (POLFIT-S, PDA_DPOLFT-D)
***KEYWORDS  CURVE FITTING, DATA FITTING, LEAST SQUARES, POLYNOMIAL FIT
***AUTHOR  Shampine, L. F., (SNLA)
           Davenport, S. M., (SNLA)
           Huddleston, R. E., (SNLL)
***DESCRIPTION

     Abstract

     Given a collection of points X(I) and a set of values Y(I) which
     correspond to some function or measurement at each of the X(I),
     subroutine  PDA_DPOLFT  computes the weighted least-squares polynomial
     fits of all degrees up to some degree either specified by the user
     or determined by the routine.  The fits thus obtained are in
     orthogonal polynomial form.  Subroutine  PDA_DP1VLU  may then be
     called to evaluate the fitted polynomials and any of their
     derivatives at any point.  The subroutine  PDA_DPCOEF  may be used to
     express the polynomial fits as powers of (X-C) for any specified
     point C.

     The parameters for  PDA_DPOLFT  are

     Input -- All TYPE REAL variables are DOUBLE PRECISION
         N -      the number of data points.  The arrays X, Y and W
                  must be dimensioned at least  N  (N .GE. 1).
         X -      array of values of the independent variable.  These
                  values may appear in any order and need not all be
                  distinct.
         Y -      array of corresponding function values.
         W -      array of positive values to be used as weights.  If
                  W(1) is negative,  PDA_DPOLFT  will set all the weights
                  to 1.0, which means unweighted least squares error
                  will be minimized.  To minimize relative error, the
                  user should set the weights to:  W(I) = 1.0/Y(I)**2,
                  I = 1,...,N .
         MAXDEG - maximum degree to be allowed for polynomial fit.
                  MAXDEG  may be any non-negative integer less than  N.
                  Note -- MAXDEG  cannot be equal to  N-1  when a
                  statistical test is to be used for degree selection,
                  i.e., when input value of  EPS  is negative.
         EPS -    specifies the criterion to be used in determining
                  the degree of fit to be computed.
                  (1)  If  EPS  is input negative,  PDA_DPOLFT  chooses the
                       degree based on a statistical F test of
                       significance.  One of three possible
                       significance levels will be used:  .01, .05 or
                       .10.  If  EPS=-1.0 , the routine will
                       automatically select one of these levels based
                       on the number of data points and the maximum
                       degree to be considered.  If  EPS  is input as
                       -.01, -.05, or -.10, a significance level of
                       .01, .05, or .10, respectively, will be used.
                  (2)  If  EPS  is set to 0.,  PDA_DPOLFT  computes the
                       polynomials of degrees 0 through  MAXDEG .
                  (3)  If  EPS  is input positive,  EPS  is the RMS
                       error tolerance which must be satisfied by the
                       fitted polynomial.  PDA_DPOLFT  will increase the
                       degree of fit until this criterion is met or
                       until the maximum degree is reached.

     Output -- All TYPE REAL variables are DOUBLE PRECISION
         NDEG -   degree of the highest degree fit computed.
         EPS -    RMS error of the polynomial of degree  NDEG .
         R -      vector of dimension at least N containing values
                  of the fit of degree  NDEG  at each of the  X(I) .
                  Except when the statistical test is used, these
                  values are more accurate than results from subroutine
                  PDA_DP1VLU  normally are.
         IERR -   error flag with the following possible values.
             1 -- indicates normal execution, i.e., either
                  (1)  the input value of  EPS  was negative, and the
                       computed polynomial fit of degree  NDEG
                       satisfies the specified F test, or
                  (2)  the input value of  EPS  was 0., and the fits of
                       all degrees up to  MAXDEG  are complete, or
                  (3)  the input value of  EPS  was positive, and the
                       polynomial of degree  NDEG  satisfies the RMS
                       error requirement.
             2 -- invalid input parameter.  At least one of the input
                  parameters has an illegal value and must be corrected
                  before  PDA_DPOLFT  can proceed.  Valid input results
                  when the following restrictions are observed
                       N .GE. 1
                       0 .LE. MAXDEG .LE. N-1  for  EPS .GE. 0.
                       0 .LE. MAXDEG .LE. N-2  for  EPS .LT. 0.
                       W(1)=-1.0  or  W(I) .GT. 0., I=1,...,N .
             3 -- cannot satisfy the RMS error requirement with a
                  polynomial of degree no greater than  MAXDEG .  Best
                  fit found is of degree  MAXDEG .
             4 -- cannot satisfy the test for significance using
                  current value of  MAXDEG .  Statistically, the
                  best fit found is of order  NORD .  (In this case,
                  NDEG will have one of the values:  MAXDEG-2,
                  MAXDEG-1, or MAXDEG).  Using a higher value of
                  MAXDEG  may result in passing the test.
         A -      work and output array having at least 3N+3MAXDEG+3
                  locations
         STATUS - Returned error status.
                  The status must be zero on entry. This
                  routine does not check the status on entry.

     Note - PDA_DPOLFT  calculates all fits of degrees up to and including
            NDEG .  Any or all of these fits can be evaluated or
            expressed as powers of (X-C) using  PDA_DP1VLU  and  PDA_DPCOEF
            after just one call to  PDA_DPOLFT .

***REFERENCES  L. F. Shampine, S. M. Davenport and R. E. Huddleston,
                 Curve fitting by polynomials in one variable, Report
                 SLA-74-0270, Sandia Laboratories, June 1974.
***ROUTINES CALLED  PDA_DP1VLU, PDA_XERMSG
***REVISION HISTORY  (YYMMDD)
   740601  DATE WRITTEN
   890531  Changed all specific intrinsics to generic.  (WRB)
   891006  Cosmetic changes to prologue.  (WRB)
   891006  REVISION DATE from Version 3.2
   891214  Prologue converted to Version 4.0 format.  (BAB)
   900315  CALLs to XERROR changed to CALLs to PDA_XERMSG.  (THJ)
   900911  Added variable YP to DOUBLE PRECISION declaration.  (WRB)
   920501  Reformatted the REFERENCES section.  (WRB)
   920527  Corrected erroneous statements in DESCRIPTION.  (WRB)
   950404  Implement status.  (HME)
   950517  Return immediately if PDA_DP1VLU returns a status.  (HME)
***END PROLOGUE  PDA_DPOLFT



next up previous 196
Next: PDA_DPOLVL - Evaluate polynomial and its derivatives as produced by PDA_DPLINT.
Up: User-callable routines
Previous: PDA_DPOLCF - Coefficients of the polynomial fit (including Hermite polynomial fits) produced by PDA_DPLINT.

PDA [1ex
Starlink User Note 194
H. Meyerdierks, D. Berry, P. W. Draper, G. Privett, M. Currie
12th October 2005
E-mail:ussc@star.rl.ac.uk

Copyright © 2011 Science and Technology Facilities Council