4.5

4.5 | 2 ratings Rate this file 24 Downloads (last 30 days) File Size: 3.01 KB File ID: #17466

weighted total least squares straight line fit

by Mathias Anton

 

09 Nov 2007 (Updated 13 Nov 2007)

Calculates the parameters (and their uncertainties) to data with uncertainties in both coordinates

| Watch this File

File Information
Description

The problem of fitting a straight line to data with uncertainties in both coordinates is solved using a weighted total least-squares algorithm. The parameters are transformed from the usual slope/y-axis intersection pair to slope angle and distance to the origin. The advantages of this are that a) global convergence is assured b) a solution is found even for a vertical line. The complete uncertainty matrix (i.e. variances AND covariance of the fitting parameters) is determined. For non-vertical straight lines the usual parameters (slope/y-axis intersect.) are also given, together with their uncertainty matrix. The algorithm is especially useful for precision measurements, where the knowledge of the complete uncertainty matrix is a must. The algorithm was published in Measurement Science and Technology 18 (2007) pp3438-3442 by M.Krystek and M.Anton, Physikalisch-Technische Bundesanstalt Braunschweig, Germany. An attached script named pearson_york_tetdata.m contains a standard statistical test data set for the problem (see e.g. Lybanon,M in Am.J.Phys.52(1)1984 pp22-26)

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
10 Nov 2007 Marcelo Perlin

Hi Mathias,

Can you provide examples scripts for the use of your function.

I'm trying it out, but I can understand in which cases your proposed method is superior to simple OLS.

What do you mean by:
uxin (standard) uncertainties of xin, same size as xin

and:
uyin (standard) uncertainties of yin, same size as yin

I would be great if you could show that (superiority over OLS and description of inputs) at an example script.

Cheers.
Marcelo

13 Nov 2007 Mathias Anton

Hi,

xin is the input (abscissa)
uxin is the standard (measurement) uncertainty of the x input. yin is the input of the ordinate and uyin the associated standard measurement uncertainty. The input vector uxin should have the same size as xin, i.e. for every x there should be an associated uncertainty value. The same holds for yin and uyin. Of course, the algorithm will yield the same result as an OLS algorithm if no uncertainties in x are present (uxin=zeros(size(xin)).

12 Nov 2009 Adam Baker  
04 Dec 2010 Hassan Radvar-Esfahlan

Hi,
I am wondering what is the uncertainties of a and b in fonction of uncertainties in xin and yin?
Thanks,

04 Dec 2010 Hassan Radvar-Esfahlan

Hi,
I am wondering what is the uncertainties of a and b in fonction of uncertainties in xin and yin?
Thanks,

09 Feb 2012 Ariel Matusevich

Dear Mathias,

There might be a little bug in your function.
Consider the following example:

x=0:50;
y=2*x;
uxin=0.001*x;
uyin=0.002*y;
[a,b,alpha,p,chiopt,Cab,Calphap]=wtls_line(x,y,uxin,uyin)

In this case, the program fails, a=0.9064 and b=NaN.

However, if you remove the first data pair (0,0):

x=1:50;
y=2*x;
uxin=0.001*x;
uyin=0.002*y;
[a,b,alpha,p,chiopt,Cab,Calphap]=wtlsc_line(x,y,uxin,uyin)

The program works perfectly well:
a=2.0000 and b=6.6781e-007.

The same problem occurs with the latest version of the algorithm (wtlsc_line).

Congratulations for your excellent work!

Kind regards,

Ariel

Please login to add a comment or rating.
Updates
13 Nov 2007

addition of a standard test data set

Tag Activity for this File
Tag Applied By Date/Time
approximation Mathias Anton 22 Oct 2008 09:34:19
interpolation Mathias Anton 22 Oct 2008 09:34:19
total least squares Mathias Anton 22 Oct 2008 09:34:19
weighted Mathias Anton 22 Oct 2008 09:34:19
uncertainty matrix Mathias Anton 22 Oct 2008 09:34:19
mathematics Mathias Anton 22 Oct 2008 09:34:19

Contact us at files@mathworks.com