LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

lev-mar multivariate data

I am trying to fit a Beam Profile, which is a 2 dimentional Gaussian and was wondering if anyone might have any suggestions on how to go about it without having to recreate too much of what is already available in LabVIEW. Thanks

Eugene
0 Kudos
Message 1 of 5
(3,130 Views)
You need to rewrite the nonlinear Lev-Mar fit so the fit funtion operates on the entire array, instead of one point at the time and everything will be much easier.

Then simply reshape your 2D gaussian data and model function to a 1D array of size (x*y) and fit as usual.


To get you started we've done some of the work for you: 🙂

Quite a while ago, David Thomson, Don Wagner and me had some discussions about improving Lev-Mar.

David has distilled a version and posted it on his site at the following link:
http://www.originalcode.com/programs_scientific.html

Look for the section "Nonlinear Fit", Version 2 (version 1 would not help much).

I have worked out a much more elaborate versions but the above should get you started.
Message 2 of 5
(3,130 Views)
This is helpful, although I still don't know how to make the changes that I would like to have. I would really like for the fit to find 2 optimal axes and fit to those, I don't know if the approach you are suggesting would do that for me or not. If you have anything more elaborate, I would appretiate you sending it my way.

Eugene
0 Kudos
Message 3 of 5
(3,130 Views)
Eugene,

Remember that the x and y values are not really needed, because they are given by the array itself.

The fit function must just calculate the 2D gaussian as another such 2D array which is then compared to the experimental data.

In your particular case, the 5 fittable variables would be e.g. [amplitude, x-center, x-width, y-center, y-width]. Your function does not need an x input at all, it is sufficient if it produces a 2D array from these 5 parameters, to be compared to the experimental array. The axes are implicit.

I am very busy today, but please contact me directly at caltenba(at)ucla.edu. Maybe send me your data and function and I'll have a look at it over the weekend. This seems not too complicated.
Message 4 of 5
(3,130 Views)
Hi,

I was looking for a similair thing today. If just changed the normal General lev marq fit routine to 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
0 Kudos
Message 5 of 5
(3,130 Views)