LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about the accuracy of the Gaussian Fit

Hi all,

 

I was having some doubts on the accuracy of the gaussian fit performed by LabVIEW and implemented the code in attachment to test it.

 

I made a distribution and made a Gaussian fit to it and extracted the average and standard deviation.

 

Then, I used the same distribution and padded it with zeros to the left and right and did a gaussian fit to the overall distribution.

 

I was expecting the average to change but the standard deviation to be the same, since the difference in the distribution are the zeros...

 

The thing is that neither the average (the average is a fractional value) nor the standard deviation are the expected.

Any hints on why this may be happening?

 

Thank you very much in advance!

 

Best regards.

0 Kudos
Message 1 of 6
(3,299 Views)

It seems to me that a more meaningful comparison would be to data sets of the same size and with the same number of zeros but different distributions of the zeros.

 

The attached modification of your VI changes the position of the replacement and returns arrays of amplitudes and standard deviations.  The variations of those values over this distributions of data sets is smaller than the difference between the original data set and any of the expanded sets.

 

Lynn

0 Kudos
Message 2 of 6
(3,275 Views)

Dear Lynn,

 

thank you very much for your input.

 

But it doesn't help understanding where the difference in the standard deviation values is coming, for instance.

 

Any input on that?

 

Thank you very much in advance!

0 Kudos
Message 3 of 6
(3,272 Views)

I do not know enough about statistics to comment on those differences.

 

Lynn

0 Kudos
Message 4 of 6
(3,265 Views)

Your data is NOT a Gaussian and fitting it to a Gaussian is thus completely meaningless. As Lynn said, the lower graph adds a sigificant amount of zeros to the dataset and thus will bias the fit.

 

You can do a "not_equal_zero...boolean_to_0,1" on the y data and wire it to the weight to disregard all zero values. Now you get the same result.

 

You should actually change the parameter bounds to allow for a fit of the offset, and you'll see that the upper graph will have a lower offset (offset=-3.6) compared to the lower graph (offset=-0.5). Since you are forcing the offset to be zero, the fit will compensate by changing the width.

 

What are you actually trying to achieve with this exercise? If this simulation is similar to your real data, maybe you should fit it to a triangle function instead. If you just want to calculate the mean and standard deviation of the data, use the classic statistics tools. Does this represent a histogram of some data?

 

 

0 Kudos
Message 5 of 6
(3,248 Views)

I just tested LabVIEW's Gaussian Peak Fit routine.  I did the following:

  1. I generated 1000 numbers with a Gaussian Distribution having Mean 5 and Standard Deviation 3.
  2. I generated a histogram of 30 bins using the Histogram VI.  Plotting it, I got something that certainly looked Gaussian.
  3. I used Gaussian Peak Fit with the Y values being the (integer) values of the Histogram bins and the X values being the bin centers.  This gave me a Mean and Standard Deviation.
  4. I wrapped all of this in a For loop, ran it 20 times, and took the Mean and Standard Deviation of the Gaussian Fit Mean and Standard Deviation.

The Mean returned by Gaussian Peak Fit had a mean of 5.03 and a standard deviation of 0.12.

The Standard Deviation returned by Gaussian Peak Fit had a mean of 2.93 and a standard deviation of 0.12.

 

Based on these data, I cannot conclude that the Gaussian Peak Fit routine returns the wrong value for mean and standard deviation of a Gaussian.

 

Note that this is not quite the same thing as saying that the Fit routine is "correct", as I'm doing a statistical test (of a statistical procedure), so all I can do is try to disprove that it does the right thing, which I could not do.

 

My conclusion, unofficially, is that the Gaussian Peak Fit routine is working properly and (probably) gives the correct value.

 

Bob Schor

Message 6 of 6
(3,232 Views)