Heaviside Function Fit
hwoarang
I'd like to fit the data with f(t) = Heaviside(t,T0)*(A(1-exp(-(t-T0)/Tth))*exp(-(t-T0)/Tel)+B(1-exp(-(t-T0)/Tel))*exp(-(t-T0)/Tdiff)).
Heaviside is defined as below. And I set all elements of the Epsilon wave 10^-6 to avoid the singular matrix error.
But the fit process didn't proceed any further iteration. In addition, there is another error message : ' fitting function returned NaN for at least one x value.'
Was I wrong for making the Epsilon wave ? Could you suggest other ways to fix this ?
Merci, in advance.
Function Heaviside(x, xo)
//+
Variable x, xo
return x < xo ? 0 : 1
//+
End
Function ReflectivityFit(w,t) : FitFunc
Wave w
Variable t
//CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
//CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
//CurveFitDialog/ Equation:
//CurveFitDialog/ f(t) = Heaviside(t,T0)*(A(1-exp(-(t-T0)/Tth))*exp(-(t-T0)/Tel)+B(1-exp(-(t-T0)/Tel))*exp(-(t-T0)/Tdiff))
//CurveFitDialog/ End of Equation
//CurveFitDialog/ Independent Variables 1
//CurveFitDialog/ t
//CurveFitDialog/ Coefficients 6
//CurveFitDialog/ w[0] = T0
//CurveFitDialog/ w[1] = A
//CurveFitDialog/ w[2] = B
//CurveFitDialog/ w[3] = Tth
//CurveFitDialog/ w[4] = Tel
//CurveFitDialog/ w[5] = Tdiff
return Heaviside(t,w[0])*(w[1](1-exp(-(t-w[0])/w[3]))*exp(-(t-w[0])/w[4])+w[2](1-exp(-(t-w[0])/w[4]))*exp(-(t-w[0])/w[5]))
End
July 15, 2011 at 01:37 am - Permalink
Thank you for replying. But, I already have checked validity of the starting guess and that it was similar graph to the the data I wanted to fit. Is there any other reason on this ?
July 15, 2011 at 06:18 am - Permalink
If they are already double-precision, if possible, create a simplified Igor experiment that shows the problem and post it here so we can play with it.
July 15, 2011 at 08:20 am - Permalink
July 15, 2011 at 04:22 pm - Permalink
The derivatives of chi-square with respect to the fit coefficients are computed by a numeric approximation. The epsilon wave is used to set the difference in a fit coefficient that is used in computing this numeric approximation. As long as epsilon for T0 is smaller than the interval between your data points, the value of chi-square doesn't change, and the derivative is zero. That results in a singular matrix error.
The only way that I have found to fit the position of a step function is to set the epsilon for the position (T0) to a value larger than the X spacing between your input data points.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 19, 2011 at 10:42 am - Permalink
July 22, 2011 at 08:27 pm - Permalink
This function works for me, the only thing I changed is adding two multiply mark between w[1] and (1-exp(-(t-w[0])/w[3])), w[2] and (1-exp(-(t-w[0]). So the function is:
return Heaviside(t,w[0])*(w[1]*(1-exp(-(t-w[0])/w[3]))*exp(-(t-w[0])/w[4])+w[2]*(1-exp(-(t-w[0])/w[4]))*exp(-(t-w[0])/w[5]))
End
September 23, 2018 at 06:09 pm - Permalink