Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

General LS Linear Fit (Not in Base Package)

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Finds the k-dimension linear curve values and the set of k-dimension linear fit coefficients, which describe the k-dimension linear curve that best represents the input data set using the least-squares solution.

Details  Examples

Y is the observed data set Y. The number of elements in Y should be equal to the number of rows in H.
H is the matrix that represents the formula you use to fit the data set {X, Y}. H[i][j] are the function values of X[i].
Weight is the array of weights for the observations Y. Weight must be the same size as Y. If Weight is unwired, this VI sets all elements of Weight to 1. If an element in Weight is less than 0, this VI uses the absolute value of the element.
covariance selector indicates whether to compute the covariance matrix.

0Do not compute the covariance matrix
1Compute the covariance matrix
algorithm specifies the algorithm this VI uses to compute Best Fit. Use the SVD for Rank Deficient H algorithm only if H is rank deficient or does not have a full rank, and all other algorithms are unsuccessful.

0SVD (default)
1Givens
2Givens2
3Householder
4LU Decomposition
5Cholesky
6SVD for Rank Deficient H
Best Fit is the fitted data computed by using Coefficients.
Coefficients is the set of coefficients that minimize chi squared. The following equation defines 2:

Covariance is the matrix of covariances C with k-by-k elements. cjk is the covariance between ai and ak. cjj is the variance of aj. This VI uses the following equation to compute the covariance matrix C:

C = (H0TH0)–1

error returns any error or warning from the VI. You can wire error to the Error Cluster From Error Code VI to convert the error code or warning into an error cluster.
mse is the mean squared error.

General LS Linear Fit Details

The following example demonstrates not only how to use the General LS Linear Fit VI to obtain the set of least square coefficients a and the fitted values but also how to set up the input parameters.

The purpose is to find the set of least square coefficients a that best represents the relationship of observations (X, Y) in the following linear data model:

where

a = {a0, a1, a2, …, an – 1}

n is the total number of functions

fi(x) are modal functions

Assume you already have a set of observations (X, Y). For example, you can obtain a set of observations through data acquisition. Also, assume you think the relationship between x and y is of the form

y = a0f0(x) + a1f1(x) + a2f2(x) + a3f3(x) + a4f4(x)

where

To obtain the coefficients a, you first obtain the matrix H, as shown in the following block diagram.

Then you obtain the coefficients a, as shown in the following block diagram.

The following block diagram shows the general programming flow for general least square linear fitting.

Examples

Refer to the following VIs for examples of using the General LS Linear Fit VI:

  • General LS Fitting VI: labview\examples\analysis\regressn.llb
  • Predicting Cost VI: labview\examples\analysis\regressn.llb
  • Linear Combinations VI: labview\examples\analysis\regressn.llb

Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit