Issue with Gaussian fit if there is a break in the data
bseay40
CurveFit/N/H="0000"/N/NTHR=0/Q gauss Table6
This yields W_coef={-26653.9, 75811, 36.241, 5.3166}
Note: I have also tried setting different values for the initial guess for the fit. Results do not change.
The problem is it seems it is only performing the fit on the block of data before the NaN values occur. So any good data after the NaN values are ignored. I've attached a graph to make this easier to visualize (graph.png). The black solid line is the original wave which includes the bad data. The dotted red line is the wave after removing the bad data points. This red curve is the one I want the fit to occur. The dotted blue line is the curve using the coefficients found after the Gaussian fit. As you can see, the fit seems to only be influenced by the data before any bad data points occurred.
I hope this is easy to understand and that I'm posting this in the right spot. Thanks for any help!
December 19, 2014 at 01:50 pm - Permalink
It is possible to force a good fit by telling Igor to use constraints. Something like:
•Make/O/T/N=5 T_Constraints
•T_Constraints[0] = {"K1 > 40000","K2 > 50","K2 < 70","K3 > 10","K3 < 20"}
•CurveFit/H="1000"/NTHR=0 gauss tester[pcsr(A),pcsr(B)] /D /C=T_Constraints
December 19, 2014 at 02:04 pm - Permalink
Here is my history report:
•CurveFit/G/NTHR=0 gauss tracemat1 /D
Fit converged properly
fit_tracemat1= W_coef[0]+W_coef[1]*exp(-((x-W_coef[2])/W_coef[3])^2)
W_coef={-31693,1.0761e+06,55.478,13.124}
V_chisq= 1.83817e+07;V_npnts= 54;V_numNaNs= 45;V_numINFs= 0;
V_startRow= 0;V_endRow= 98;
W_sigma={109,4.93e+04,0.0212,0.0906}
Coefficient values ± one standard deviation
y0 =-31693 ± 109
A =1.0761e+06 ± 4.93e+04
x0 =55.478 ± 0.0212
width =13.124 ± 0.0906
Note the starting guesses that set the amplitude quite high, and the width pretty large. Note also that the resulting fit has a *really* large amplitude.
I have attached a graph of my fit. Note that you are asking a lot of this fit!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
December 19, 2014 at 03:29 pm - Permalink
I was able to get it to work while keeping the NaNs in the wave. I was never able to get it to fit properly by adjusting the initial guesses. However, for all of my cases I ~ know what the width of the Gaussian is going to be. Setting a constraint of K3 > 10 has fixed the problem for all of my cases.
Thanks again.
December 23, 2014 at 05:17 am - Permalink