02-27-2009 08:33 AM
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.
03-03-2009 10:34 AM
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.
03-03-2009 11:43 AM
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
03-19-2009 11:05 AM
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
03-19-2009 12:27 PM
(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. 😉