help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weighted polyfit?


From: Ben Abbott
Subject: Re: Weighted polyfit?
Date: Fri, 26 Mar 2010 09:42:16 -0400

On Mar 26, 2010, at 5:36 AM, 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

Have you looked at wpolyfit.m from the optim package?

        http://octave.sourceforge.net/optim/function/wpolyfit.html

Ben






reply via email to

[Prev in Thread] Current Thread [Next in Thread]