|
From: | Andreas Stahel |
Subject: | Weighted polyfit? |
Date: | Fri, 26 Mar 2010 15:02:26 +0100 |
User-agent: | Thunderbird 2.0.0.23 (X11/20090817) |
On 26 Mar 2010, at 10:36, Matthias Brennwald wrote:
> Dear all > > I am pretty sure this is something that has been discussed > previously, but I was not able to find anything helpful. I'd like to > fit a polynomial to my experimental data. The data have errors, and > I'd like to use these errors as weights for the data values in the > fit. Something like this: > > x = [0:10]; % x values of experimental data > y = x.^2; % y values of experimental data > y_err = randn(size(x)); % errors of y > [p,s] = polyfit (x,y,2); % <-- replace this by something that > takes into account the errors (y_err), e.g. using the weights 1./ > y_err for each value in y > > Any hints or ideas? > > Matthias
The function LinearRegression.m in the sourceforge package optim allows to specify weights and can be used to do polynomial regression. A Vandermonde matrix (command vander()) might be useful to call LinearRegression.
I hope this helps Andreas -- Andreas Stahel E-Mail: address@hidden Mathematics, BFH-TI Phone: ++41 +32 32 16 258 Quellgasse 21 Fax: ++41 +32 321 500 CH-2501 Biel WWW: https://prof.ti.bfh.ch/sha1/ Switzerland
[Prev in Thread] | Current Thread | [Next in Thread] |