CLsqFit:Basis Functions CLsqFit:Working with RGB data

Using Multiple Independent Variables


A fit can be computed for data having between 1 and 10 independent variables, or basis dimensions. For example, fitting a curve to (x,y) pairs estimates the function y(x) and involves 1 independent variable, x, and an observation, y, which is the observed value at coordinate x. Fitting a surface z(x,y) involves 2 independent variables, x and y. The independent variables are specified as basis dimension 1 for y(x) and as basis dimensions 1 and 2 for z(x,y). The CLsqFit class accommodates up to 10 basis dimensions, or independent variables. It also fits up to 100 coefficients which may be mixed among the variables. The interaction between coefficients and basis dimensions is controlled by the basis function. Some examples will illustrate this concept. Coefficients are represented by a[n] where n is in the range 1 through 100.

bullet.gif    A line is fit by the equation y = a[1] + a[2]x. This has 1 independent variable, x, and 2 coefficients, a[1] and a[2]. You could force the slope a[2] to, say, 1.0 and fit only the intercept a[1] using the ForceCoef method. This still involves setting 2 coefficients but one of them is subsequently forced.

bullet.gif    Fitting a general polynomial curve y=f(x) involves 1 basis dimension for x but n coefficients in a polynomial of degree n. The equation being fit is y = a[1] + a[2]x + ... + a[n]x^(n-1).

bullet.gif    Fitting a plane z = a[1] + a[2]x + a[3]y involves 2 dimensions, x and y, but 3 coefficients, a[1] through a[3].

bullet.gif    A warped plane involves a cross term that couples x and y through the equation z = a[1] + a[2]x + a[3]y + a[4]xy. This involves 2 dimensions and 4 coefficients.

bullet.gif    A general 2-dimensional polynomial involving all cross terms has m x n coefficients in 2 dimensions. An example is illustrated by the warped plane which has m=2 and n=2, making 4 coefficients in total. For m=3, n=2, the equation is z = a[1] + a[2]x + a[3]x^2 + a[4]y + a[5]xy + a[6]x^2y. This latter equation has dimension 2 and 6 coefficients. A 5x7 polynomial of 2 dimensions would have 35 coefficients. You can remove coefficients from the fit by forcing them to specific values (see Forcing Coefficient Values). For example, to remove all cross terms from this fit, specify a 3x2 (6 term) fit and then use use ForceCoef( 5, 0 ) and ForceCoef( 6, 0 ) to force a[5]=0 and a[6]=0. Multiple coefficients are specified for the n-dimensional polynomial with n > 1 are specified using a table, like {3,2} in the present example.

As can be seen from these examples, higher order multi-dimensional fits may involve complicated equations. Thus the CLsqFit class includes 2 useful built-in fitting functions: an n-dimensional polynomial fit of up to 100 terms including all cross terms, and a hyperplane function for fitting up to 10 independent variables of first power only. Other basis functions can be specified by writing them as a script function; see Basis Functions and the SetBasisFunc method.

Related Topics

CLsqFit class

Basis Functions

Forcing Coefficient Values

 


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.