[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: leasqr
From: |
Paul Kienzle |
Subject: |
Re: leasqr |
Date: |
Wed, 23 Jan 2002 11:19:28 -0500 |
Christian,
When you are fitting, you want to have as smooth a space as possible. You
definitely will not get this when you are trying to fit a sin function
because you will have local minima at the harmonics.
A much better approach in this case is to find the peak in the fourier
transform. This will give you a good initial guess for all three of
frequency, amplitude and phase, which you can then refine using leasqr.
Or you could use something like the MUSIC algorithm (search for pmusic to
get the matlab documentation). A variation of this is available as
spcline/musicsp.m in:
ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/tools/spctools/software/spcjune.tar
You may need some functions from octave-forge and minor editting for this
to run. I don't recall if I ever tried it, but other functions from the
directory worked fine for me.
If you do use pmusic, or other functions from spctools, please ask the
author for permission to include them in octave-forge along with a license
which allows us to modify and redistribute them (e.g., GPL or X11 or public
domain). Thanks.
Paul Kienzle
address@hidden
On Tue, Jan 22, 2002 at 05:35:29PM -0600, Christian T. Steigies wrote:
> 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
> -------------------------------------------------------------
>
-------------------------------------------------------------
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
-------------------------------------------------------------
- leasqr, Christian T. Steigies, 2002/01/22
- Re: leasqr,
Paul Kienzle <=