Table of ContentsNext


The Basis Option

The default basis function for LinearFit is the Mathematica function Power, which causes LinearFit to fit to polynomials. It may be changed to a user-supplied function using the Basis option.

In Mathematica Power[x,n] is a synonym for x^n.

In verbose mode, the form to change the Basis looks like this:

Basis


(default: x^n)

Defines the model to which the fit will be performed, by specifying the basis functions. This is a Mathematica expression given in terms of x (the independent variable) and n (the factor).

The default value of Basis is x^n, and specifies that the basis functions are simply powers of the independent variable; this means that the default model for the fit is a polynomial, and the factors are the desired powers.

To change the basis function to, say, a sum of sines, one may set this option to Sin[2 n Pi x]. Then if the requested factors are 1, 2, and 3, the fit will be to: y = A1 Sin[2 Pi x] + A2 Sin[4 Pi x] + A3 Sin[6 Pi x].

Our illustration will use some made-up data which is a linear combination of three Bessel functions with a small noise. Here is some Mathematica code that would generate such a data set:

[Graphics:../Images/index_gr_2.gif]

We change the Basis by typing directly in the text field. In this example is should look like:

Basis


(default: x^n)

Defines the model to which the fit will be performed, by specifying the basis functions. This is a Mathematica expression given in terms of x (the independent variable) and n (the factor).

The default value of Basis is x^n, and specifies that the basis functions are simply powers of the independent variable; this means that the default model for the fit is a polynomial, and the factors are the desired powers.

To change the basis function to, say, a sum of sines, one may set this option to Sin[2 n Pi x]. Then if the requested factors are 1, 2, and 3, the fit will be to: y = A1 Sin[2 Pi x] + A2 Sin[4 Pi x] + A3 Sin[6 Pi x].

where BesselJ is the Mathematica built-in Bessel function routine.

In performing the fit, we would then choose the factors to be 1, 2 and 3:

Step 2: Select the factors for the fit

Next, select the factors n for the basis functions you wish to use in the fit:
Enter them directly, separated by commas or spaces:
Or toggle these checkboxes:
0 1 2 3 4 5 6 7 8 9

The result of performing this fit is:

A1 = 20.19 ± 0.20
A2 = 4.67 ± 0.25
A3 = 2.18 ± 0.25
Sum of Squares = 8.63837 for 98 Degrees of Freedom
(Assumed statistical error in the dependent variable: 0.296895
[Graphics:../Images/index_gr_5.gif]

There are two points to emphasise in the above.

First, the variable name x has no relationship to any variable names that you may have assigned to your data: it will be invisibly converted to the values of the independent variable of your data set. Similarly, the variable name n is what is called the "factors" (or the "powers of the fit" when fitting to the default basis function, which is a polynomial).

Second, we can use the linear fit routine to do the above fit since the model is linear in the amplitudes of the Bessel functions. If we were trying to determine, say, which orders of Bessel functions combined to fit the data we would need to use a nonlinear fitter. Further information on the distinction between a linear and nonlinear fit may be found here.


Table of ContentsNext


Authors

This help document is Copyright © 1999 David M. Harrison. The sample screens are Copyright © 1999 Solomon R.C. Douglas and David M. Harrison. This is version 1.1 of the help document, date (m/d/y) 11/25/99.