From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Gaussian Peak Fit vi - valley fitting

Hi Everyone

I have been looking for this info everywhere and could not find it.

Is it possible to use the function Gaussian Peak Fit to fit a valley?

How to set parameter bounds for that case?

Looking forward to your suggestions.

Best regards,

   Joao

PS: I am using Labview 2012. If you send any example, could you please take that into account?

0 Kudos
Message 1 of 5
(2,772 Views)

I'm not sure what you mean by "fit a valley" -- are you trying to fit data with the negative of a Gaussian?  Something that is flat far away from the valley, then dips down "as though it was a Gaussian"?  If this is the case, take your data, multiply it by -1, fit a Gaussian, then negate the "bias" and "gain" components of the model.

 

Bob Schor

0 Kudos
Message 2 of 5
(2,771 Views)

Hi Bob

Thank you for the suggestion.

In fact I had already used it, but my concern is if that is the best solution.

I have tested with a curve to which I added different amounts of noise. I varied the parameter values but could not reach a conclusion. Sometimes the value of the peak is affected, sometimes it does not.

 

I really do not understand the exact meaning of each of the "parameter bounds" in Gaussian Peak Fit vi.

 

I need a criterium and the help text is not clear enough.

 

I wonder if you, or some one else in this forum, could point me to an article or a book where I could find a thoughrough explanation of that function.

 

Loking forward for a reply.
Best regards,
Joao

0 Kudos
Message 3 of 5
(2,733 Views)

Joao,

 

     I think you may have found something "interesting".  I hadn't tried using the Gaussian Fit routine, myself, so I generated a "Gaussian Valley" dataset and tried to do a fit.  When that didn't work, I tried to fit a Gaussian Peak.

 

     I also don't understand what it is doing!  Either I'm doing something entirely wrong, or I don't understand the Help and am using the function incorrectly, or it just doesn't work.  I'll play with this a bit more, and see what I can find out.

 

Bob Schor

0 Kudos
Message 4 of 5
(2,719 Views)

Joao,

 

     I think I figured out the problem with the Gaussian Curve Fitting VI.  I (now) believe it works exactly as it is designed to work, but that there is a "silliness" in its design that is (very) easy to overlook.

 

     I quickly read the Help entry for this Function, especially the Gaussian Peak Fit Details (which were exactly what I was expecting they were doing, so I thought I really knew what the Function was doing.  I was wrong ...

 

     Look at the input Control "Parameter Bounds".  This allows you to "clamp" the value of any of the Parameters to optimize the Fitting Procedure (after all, if you know the value of the Peak, say, you should treat it as a Constant when you do the fit, speeding up the code).  All of the values of this Control are, by default, set to "Allow All Values" except "Offset", which is set to 0!  As it happens, I was testing with a non-zero Offset, and was confused by how poorly the Fit behaved.

 

     I'm attaching a pair of VIs that I wrote for myself to test my "new understanding" of this function.  It allows you to generate data whose amplitude is either a Gaussian Peak (Amp > 0) or Gaussian Valley (Amp < 0).  I also tried out a little routine to make an initial Guess for the Gaussian Parameters -- in some cases, particularly when the data are noisy, this helps, but for many test cases, the fits with and without Initial Guesses are essentially the same.

 

     To see the effect of using the default values for Parameter Bounds, try running the Test routine with this Cluster disconnected from Gaussian Peak Fit -- the resulting fit is way off.

 

     Note that the Gaussian Peak Fit doesn't need to be modified at all to fit a Gaussian Valley -- it does a fine job, returning a negative Amplitude (saying that the "Peak" is less than the "Offset", or a Valley).

 

     Hope this "solves" this issue for you.

 

Bob Schor

 

Download All
0 Kudos
Message 5 of 5
(2,707 Views)