From help-octave-request at bevo dot che dot wisc dot edu Tue Jan 22 17:36:20 2002 Subject: leasqr From: "Christian T. Steigies" To: help-octave at bevo dot che dot wisc dot edu Date: Tue, 22 Jan 2002 17:35:29 -0600 Hi, I am trying to use "leasqr" which I found in the octave-forge (debian) package. The demo works really nice, but I am trying to fit to a sin function, very simple, three parameters, amplitude, frequency and phase. It is working fine when the data consists of less than one period(?). It also works sometimes for a few periods when my starting values are close to the actual parameters. How sensitive is leasqr to the starting parameters? And why is it so difficult to fit to a sine? My math lectures are some time ago and it seems I did not pay much attention during optimization... I am not fitting to real data yet, I just generate my data points, no noise added. I tried both, analytic dfdp and the dfdp function (which I found via mathtools.net(?). I hope the derivative is correct: function y = leasqrfunc(x,p) y = p(1)*sin(p(2)*x + p(3)); endfunction function y = leasqrdfdp(x,f,p,dp,func) y= [sin(p(2)*x+p(3)), p(1)*x.*cos(p(2)*x+p(3)), p(1)*cos(p(2)*x+p(3))]; endfunction octave2.1 2.1.35-5 Any hints, books, webpages, FAQs, welcome. Christian ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------