I am confused using the Gauss Peak Fit function and it's weights input.
My goal is to eliminate the sharp peak in the input data (white). Now, I see that the overall tendency is a Gauss shape.
My first attempt was to introduce a weighting that would prefer the outer data instead of the central ones (that is "weight1 (no zero weights)" -- red V-shaped curve). Well, I've got a Gauss curve that is not so good ("Gauss1" -- red curve).
My next attempt was to set some weight values in the center to zero ("weights2 (some zero-weights)" -- blue dots with zeros at center time). Surprise, surprise, it has got even worse ("Gauss2"-- blue curve).
So, I deleted I set some values in the amplitudes to NaN -- those values which are part of the sharp peak. The results is not publishable at all.
As next, I deleted the 7 dots around the center completely and fitted the two wings of the input data. Then I interpolated the missing rest and came up with "Gauss3" -- the orange curve.
As a cherry on the top of it. I glued the original data with the interpolated Gauss3 to finally get rid of the sharp central peak.
My question is: Why did Gauss Peak Fit ignored my weights? According to the help, they should not be non-zero; that is all.
Solved! Go to Solution.
I agree that the gaussian fit does a poor job with weighting enabled. The code is opaque, so I cannot tell what is going on, but since there are no parameter estimates, My guess is that they give poor estimates is the center of the peak is missing. Maybe it is generally fragile code. Sorry, I don't know.
I strongly recommend to use the nonlinear fitting and make an explicit gaussian model. Now the fits seem to work just fine and as expected. See attached modification of your code.
The problem may be due to the 'parameter bounds' input to the Gaussian Peak Fit.vi. By default the offset min and max are both 0, forcing the offset parameter to be 0. When I changed the offset min and max for all three instances of the Gaussian Peak Fit.vi to be unconstrained (-Inf, Inf), then the fit was much better.
Yes, thank you, Jim, that made it work. I set the offset bounds to (0, 1e-16) and it worked, too, i.e. it ignored the sharp peak and fitted the Gaussian wings with a zero offset. Offset bounds = (0, 0) fails, though. So, there is still something fishy about the optimization, IMO.
Thank you, Altenbach, too!
I agree, there is still something not quite right. Seems to be in our initial guess code. A bug report has been filed to fix the problem. In the meantime, given that the initial guess code seems to be the problem, please supply your own initial guess if you have any doubts.
I set the offset bounds to (0, 1e-16) and it worked, too,
That's a strange choice for the bounds. What is the reasoning?
A small change in the input values (in our case the offset limits) makes a huge difference in the results. That makes me allert and curious. The issue seems to be explained by Jim, I check on the initial guess and report back.
OK, so if any of the initial guesses is NaN, the optimiastion fails as described above.
The guess above makes some of the Guass optimisations works well, see below.
I am happy with the solution for now, and I am also happy that I could push some corrective actions forward 🙂
Thank you all! Cheers,