functions in poly.i -
plpwf
|
plpwf, y, x; -or- c= plpwf(y, x); plot data as points with polynomial fit. When called as a subroutine, prints out the coefficients of the polynomial. When called as a function, returns the polynomial coefficients. KEYWORDS DEGREE polynomial degree, default 1. COLOR color for the plot (data points and curve fit). SYMBOL symbol shape (see plp). | |
SEE ALSO: | plp, poly1_fit |
poly1
|
: poly1(x, c); Returns value of the 1D polynomial: C(1) + C(2)*X + C(3)*X^2 + ... | |
SEE ALSO: | poly, poly1_deriv, poly1_fit, poly2 |
poly1_deriv
|
: y= poly1_deriv(x, c); Returns value of the derivative of the 1D polynomial: C(1) + C(2)*X + C(3)*X^2 + ... in other words: Y= C(2) + 2*C(3)*X + 3*C(4)*X² + ... | |
SEE ALSO: | poly1 |
poly1_fit
|
: c= poly1_fit(y, x, m); -or- c= poly1_fit(y, x, m, w); Returns coefficients of the 1D polynomial of degree M: C(1) + C(2)*X + C(3)*X^2 + ... + C(M+1)*X^M which best fits Y in the least squares sense: C = arg min sum(W*(poly1(X,C) - Y)^2) The weights W are optional (by default, W=1.0). The array X and Y must have the same shape. | |
SEE ALSO: | poly1 |
poly1_gcv_fit
|
c= poly1_gcv_fit(y, x); -or- c= poly1_gcv_fit(y, x, w); Apply Generalized Cross Validation criteria to select the best polynomial that fits Y(X). For each increasing polynomial degree, the ability of the model to predict measured values is estimated by: GCV_CHI2 = sum_i [ W(i) * (PREDICTED(i) - Y(i))^2 ] where PREDICTED(i) is the value at X(i) of a model that fits all data points (X,Y) but the Ith one (i.e. the point (X(i),Y(i)) is missing). One can expect that, for too simple models (too low polynomial degrees) GCV_CHI2 will be large due to the inability of the model to fit the real behaviour of the data. Besides, as models get more complicated, they tend to also fit the noise contribution in the data in, thus yield large value for GCV_CHI2. Where W is the optional third argument: weight for Y (default 1.0). The coefficients C returned by poly1_gcv_fit correspond to the `best' fit: the less complicated model for which GCV_CHI2 is minimal. KEYWORDS DEGREE Polynomial degrees to check as: [DEGREE_MIN, DEGREE_MAX] or just DEGREE_MAX (DEGREE_MIN will be 0), default [0, numberof(y)-2]. VERBOSE Flag: print out polynomial degree and GCV value. ALL Force checking of all the degrees between DEGREE_MIN and DEGREE_MAX. The default behaviour is to stop when the 1st minimum is found. Should only be used with VERBOSE=1 or GET_INFO=1. GET_INFO Flag: return misfit information? The default is to return the coefficients of the best polynomial fit. With this flag, the result is: C(1,)= polynomial degree C(2,)= sqrt(GCV_CHI2/sum(W)) | |
SEE ALSO: | poly1_fit |
poly2
|
: poly2(x1, x2, c); Returns value of the 2D polynomial: C(1) + C(2)*X1 + C(3)*X2 + C(4)*X1^2 + C(5)*X1*X2 + C(6)*X2^2 + ... X1 and X2 must be conformable. For a 2D polynomial of degree 1, 2 or 3 (3, 6 and 10 coefficients respectively) poly2 uses hard-coded factorized expressions to minimize the number of operations. | |
SEE ALSO: | poly, poly1 |
poly2_deriv
|
drv= poly2_deriv(x1, x2, c); Return derivatives of 2D polynomial poly2(X1,X2,C) with respect to X1 and X2: DRV(..,1)= d poly2(X1,X2,C) / d X1 DRV(..,2)= d poly2(X1,X2,C) / d X2 BUGS: Only works for polynomials of degree 1 to 4 (needs factorization for degree 4). */ |
poly2_fit
|
: c= poly2_fit(y, x1, x2, m); -or- c= poly2_fit(y, x1, x2, m, w); Returns the (M+1)*(M+2)/2 coefficients of the 2D polynomial of degree M: C(1) + C(2)*X1 + C(3)*X2 + C(4)*X1^2 + C(5)*X1*X2 + C(6)*X2^2 + ... which best fits Y in the least squares sense: C = arg min sum(W*(poly2(X1,X2,C) - Y)^2) The weights W are optional (by default, W=1.0). | |
SEE ALSO: | poly2 |
solve_lfit
|
x= solve_lfit(data, ptr); -or- x= solve_lfit(data, ptr, wght); Return solution of a weighted least square linear fit: X= arg min sum( WGHT * (MODEL(X) - DATA)^2 ) where the model is obtained by linear combination of the "basic model components" stored in the array of pointers PTR: MODEL(X)= X(1) * *PTR(1) + ... + X(N) * *PTR(N) where N=numberof(PTR). Each component *PTR(i) must be conformable with the DATA array. If the weights WGHT array is missing, the result is the same as with WGHT=1.0 (actually WGHT set to any strictly positive scalar yields the same result). | |
SEE ALSO: | poly1_fit, poly2_fit |