help-octave
[Top][All Lists]
Advanced

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

Re: polyfit with a fixed slope ??


From: Carlo de Falco
Subject: Re: polyfit with a fixed slope ??
Date: Tue, 25 May 2010 15:50:00 +0200


On 25 May 2010, at 15:24, Carlo de Falco wrote:


On 25 May 2010, at 14:20, Oisín Ó Cuanacháin wrote:

Hi,

Does anyone know if there is a function to fit a line with a specified slope to some data. I have a load of data 'x' and polyfit(1:length(x),x,1) gives me the best-fit line, with arbitrary slope. What I want however is the best fit line with a particular slope. This is essentially just a minimization problem and I know I could code something up myself, but x has 100's of millions of elements I'm guessing my coding efforts will take forever to run, so does such a nice function already exist? It is essentially polyfit with an added constraint that the slope is fixed.

Thanks,

Oisín.

If I understand correctly, given two data vectors x and y and a slope a you want to find the value b that minimizes

R(b) = sum ((a*x + b - y).^2);

isn't that just

b = sum (a*x-y)/2

sorry, I think it's
b = - sum (a*x-y)/2

?
c.



reply via email to

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