LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Gaussian Fit with LM - I am having problems !

I have this spectrum that I am trying to fit to a gaussian with extra terms.The usual gaussian + slope + offset

 

f(x) = a*exp(-(x-mu)*(x-mu)/(2*sig*sig)) + slope*x + offset

 

I fit seems to be alright in most cases but I have this unique problem. The actual fit that I compute seems alright but the fit estimates are off. It keeps changing when I vary the termination constant. I am not sure what I can do to fix the problem. Any inputs are welcome. I am attaching the VIs with the data in them. Please open both of them and run GaussianFit.vi.


Kudos are the best way to say thanks 🙂
Download All
0 Kudos
Message 1 of 5
(3,424 Views)

Spartan00,

 

I presume you have already looked at the shipping example "Fit sum of 3 gaussians with offset.vi". If not, you could start there and modify it to your needs. 

 

There's also an example by altenbach that fits a single Gaussian or Lorentzian (selectable) here and a similar discussion in this thread

 

Hope this helps. 

 

 

Misha
Message 2 of 5
(3,382 Views)

Looks like you are converging to a set of parameters that are unexpected.  Try using the "Constrained Nonlinear Curve Fit.vi" instead, and use some common sense bounds for your variables.  For eaxmple, bound the center parameter using the same criteria you are using for getting your data subset (center*.6, center*1.4).  This will constrain the solution to be something that makes sense. 

 

-Jim

Message 3 of 5
(3,374 Views)

Was this problem solved?  I have a similar problem with many lorentzians and a similiar offset.

 

Also could someone save this is 8.5 so I can see the original VIs.

 

Thanks a lot in adv,

 

Thom 

0 Kudos
Message 4 of 5
(3,300 Views)

(Well, that would not really help you since his version does not work well either. My best guess is that the data is not really a gaussian in the above case....)

 

 

Anyway, can you tell us a bit about your problem? Typically, this will be solved by defining reasonable parameter estimates.


Tesla229 wrote:

Was this problem solved?  I have a similar problem with many lorentzians and a similiar offset.


Do you mean you are fitting a function that consists of many Lorentzians or do you fit a single lorentzian and it fails with many datasets? (big difference!).

 

Why don't you show us your code and some typical data and I we'll see what the problem really is. 😉

Message 5 of 5
(3,291 Views)