LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Least square fit in the Advanced Analysis library

Hello all,
I'm a little rusty when it comes to fitting a function to data, and the
GenLSFit function is intimidating ! And unfortunately doesn't come with an
example.

Say I have a 1D array Y[..] containing data of the form
exp(-i/t).(a.sin(M.i)+b.cos(M.i))
I'm looking for a and b (I already know t and M).

First question:
- do I have to use GenLSFit or can I use of of the simplified forms like
LinFit and Co (this function is obviously not linear in 'i') ?

- What do I need to feed GenLSFit ? The first parameter should be a 2D
matrix. Where does that come from and where do my Y array and my function go
?

Thanks
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 1 of 3
(3,407 Views)

Hi Guillaume.

I suggest you try either NonLinearFit() or NonLinearFitWithMaxIters() from the Advanced Analysis Library.

According to the function help, GenLSFit() finds "...the best fit k-dimensional plane ...", i.e. it appears to be suitable only for linearly related data.

Regards,
Colin.

0 Kudos
Message 2 of 3
(3,386 Views)
> I suggest you try either NonLinearFit() or
> NonLinearFitWithMaxIters() from the
> Advanced Analysis Library.
> According to the function help, GenLSFit() finds "...the best fit
> k -dimensional
> plane ...", i.e. it appears to be suitable only for linearly related data.

Thanks, I'd missed that one. Works like a charm.
I'm fitting a function to an array that is very close to the function, so I
thought the convergence would be excellent, but I had to use the MaxIter
feature: with some initial values I get instant convergence and with other
(close) values, after 10 minutes the CPU is still chugging along. I guess it
takes a full mathematical treatise to know why, right ?
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 3 of 3
(3,378 Views)