LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Non-linear Lev-Mar Fit for Multivariate Data

Hi --

I've am trying to fit a function having two independent variables of the
form, z = f(x,y) containing a couple of parameters, alpha and beta, to be
determined by regression. My function looks like:

z = (a + alpha * x) * (1-exp(-beta * y/x))

The function is also numerically ill-behaved (or at least tempermental 🙂

My only LabView option is the Non-Linear Lev-Mar Fit algorithm as my
function can't be linearized by any transformation to coerce it to a form
where a generalized least squares linear fit would work. On the other hand,
it looks like the Lev-Mar Fit vi can only handle functions having a single
independent variable.

Does anyone know of any libraries having a routine that can do the job?

Si
ncerely,

John

P.S. - There is a charting program called Kaleidograph with a L-M fit
routine that does this nicely but I need a seemless LV interface.
0 Kudos
Message 1 of 9
(5,734 Views)

Hi John,

the nice trick about the NLLM Vis is that they are pure G, so you can
copy and customize them. Fitting a multivariate function is possible if
you modify the Vi to allow for a multivariate input that you will
flatten into a 1D array to use the available code. In the Function &
Derivative Vi, you will have to provide an extra input that will allow
you to recover the different variables corresponding to a given index in
your flattened 1D array.
HTH,
Xavier.

"John M. Jarvis" wrote:
>
> Hi --
>
> I've am trying to fit a function having two independent variables of the
> form, z = f(x,y) containing a couple of parameters, alpha and beta, to be
> determined by regression. My function looks like:
>
> z = (a + alpha * x) * (1-exp(-beta * y/x))
>
> The fun
ction is also numerically ill-behaved (or at least tempermental 🙂
>
> My only LabView option is the Non-Linear Lev-Mar Fit algorithm as my
> function can't be linearized by any transformation to coerce it to a form
> where a generalized least squares linear fit would work. On the other hand,
> it looks like the Lev-Mar Fit vi can only handle functions having a single
> independent variable.
>
> Does anyone know of any libraries having a routine that can do the job?
>
> Sincerely,
>
> John
>
> P.S. - There is a charting program called Kaleidograph with a L-M fit
> routine that does this nicely but I need a seemless LV interface.

--
________________________________________
Xavier Michalet, Ph D

[edited by moderator to remove private information - 07/14/2015]

0 Kudos
Message 2 of 9
(5,734 Views)

Hi Xavier --

Thanks for the idea.

It wasn't quite as easy as flattening data and then indexing into it to
recover the independent variables but it wasn't too painful either. Rather
than flatten the data, I left it in two dimensions and modified all of the
three calling routines. Had to fiddle with the indexing a bit but nothing
too esoteric.

Sincerely,

John M. Jarvis, Ph.D.


Xavier Michalet wrote in message
news:38EE593A.F3FCDC43@lbl.gov...
> Hi John,
>
> the nice trick about the NLLM Vis is that they are pure G, so you can
> copy and customize them. Fitting a multivariate function is possible if
> you modify the Vi to allow for a multivariate input that you will
> flatten into a 1D array to use the available code. In the Function &
> Derivative Vi, you will have to provide an extra input that will allow
> you to recover the different variables corresponding to a given index in
> your flattened 1D array.
> HTH,
> Xavier.
>
> "John M. Jarvis" wrote:
> >
> > Hi --
> >
> > I've am trying to fit a function having two independent variables of the
> > form, z = f(x,y) containing a couple of parameters, alpha and beta, to
be
> > determined by regression. My function looks like:
> >
> > z = (a + alpha * x) * (1-exp(-beta * y/x))
> >
> > The function is also numerically ill-behaved (or at least tempermental
🙂
> >
> > My only LabView option is the Non-Linear Lev-Mar Fit algorithm as my
> > function can't be linearized by any transformation to coerce it to a
form
> > where a generalized least squares linear fit would work. On the other
hand,
> > it looks like the Lev-Mar Fit vi can only handle functions having a
single
> > independent variable.
> >
> > Does anyone know of any libraries having a routine that can do the job?
> >
> > Sincerely,
> >
> > John
> >
> > P.S. - There is a charting program called Kaleidograph with a L-M fit
> > routine that does this nicely but I need a seemless LV interface.
>
> --
> ________________________________________
> Xavier Michalet, Ph D

[edited by moderator to remove private information - 07/14/2015]

0 Kudos
Message 3 of 9
(5,734 Views)
Hi John

was wondering if you could forward on your modified VIs for handling fitting of f(x,y) data.

cheers

stu
0 Kudos
Message 4 of 9
(5,734 Views)
John

Nice extension. I'm facing the same fitting.
Excel solver can do it as well.

Johnnason
0 Kudos
Message 5 of 9
(5,734 Views)
Hi! I have to use a two dimensional fit, too. I want to fit a gauss and top hat. So is there a possibility to get your Lev-Mar.vi for f(x,y)-functions?
Thanks and good bye
0 Kudos
Message 6 of 9
(5,734 Views)
I'm interested too.
is ther any place too download it??
Greeting from Ruedi
0 Kudos
Message 7 of 9
(5,734 Views)
John,

Is the any way to get your code, I am trying to fit a 2D Gaussian.

Thanks

Eugene
0 Kudos
Message 8 of 9
(5,734 Views)
I found this tread today looking for the same thing. I've made some modification to the Standard Lev Mag fit routine in order to fit N-variable data (for instance 2D data.) I've added a Lib in LV6.1 for those interested. in the code. It is a bit rough but it should be ok. Levenberg Marquardt Nd.vi is the fit routine. Use model discription to enter the formula to fit to. Furthermore there is "Test 2d fit.vi" that generates a 2d Gaussian and then fits this function to it.

Hope this helps let me know if you like it (see address in the VI) or run into problems.

Erik van Dijk
Message 9 of 9
(5,734 Views)