LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fitting array data with downhill simplex method

Hi, I would like to use the downhill simplex nD vi to fit various functions (such as gaussians)  to spectral data as I am interested in using this vi to varify another method of fitting. I have trouble programming all of my initial parameters into the vi and I now suspect that the labview version of this code will not do what I want. I have the following; 1) the function that I want to fit; 2) an initial guess of the parameters for the coefficents of the function; 3) the x and y data (as arrays)).
In the downhill simplex nD there appear to be four inputs, accuracy, start, x and fx.
See:http://zone.ni.com/reference/en-XX/help/lv/71/gmath/Downhill_Simplex_nD/
start; appears to be your initial guess numbers
x; a string of names for the variable labels in fx
fx; a string forming the function that you wish to minimise.
How do I get the x and y arrays of data into the fx string? I don't get it. Can someone please explain what I need to do?
Thanks for your time, Dan_aus. (package: labv7.1 prof)

0 Kudos
Message 1 of 5
(3,432 Views)
Downhill Simplex nD.vi finds a local minimum of a function. 
Based on what you said, you can try Levenberg Marquardt.vi to perform fit.
0 Kudos
Message 2 of 5
(3,429 Views)
Thanks for your message, ttrr. Is it possible to encode the downhill simplex vi to perform the optimisation? In matlab for example it allows additional parameters to be included so that the x and y data is included. I'm actually trying to test out different methods of optimisation so while I could use the Levenberg-Marquardt vi I was hoping that I could recode the simplex to do the same thing. Maybe it is not possible???? I think that the x,y data would have to be held in the fx string definition which all seems very complicated! Dan_aus
0 Kudos
Message 3 of 5
(3,424 Views)
I write a VI which performs linear fit on y=a*x+b. Downhill Simplex nD.vi is invoked to minimize the least-square rule. Just try it.
I think the problem is how to decide and generate a proper string which represents function you want to mininize.
0 Kudos
Message 4 of 5
(3,414 Views)

ttrr is right..

Non-linear fits are very sensitive to inital guess and step size.  I've used the Numerical Recipies Ameoba routine a lot, and while it does work well, it's not quite a "Hands off" sort of thing.  Depending on SNR, and the degrees of freedom, it can take some hand-holding to get it to converge.  Too small a step size and the routine can get stuck in a local "wrinkle", to large a step size and it can jump right over the minumum you are looking for and into no-mans-land. 

I wrote up a gaussian fit vi that uses the Levenberg-Marquardt routine, and makes an initial guess based on input array max/min and location of the max.  It calculates a rough FWHM to feed as an initial condition as well.  For the cases I've used this routine on, it's been quite robust and reliable. 

Sheldon

Technical geek, engineer, research scientist, biodegradable...
0 Kudos
Message 5 of 5
(3,398 Views)