Fitting a discontinuous function?

Is there a way to fit a discontinuous function using Igor? More specifically, I have some kinetic data that demonstrates a lag time, L, which is followed by an exponential growth. The function would be y(x) = 0, if x < L and y(x) = y0 + A*exp(-kt), if x > L.
This should work. You may want to hold w[0] if you know what the lag time is.
Function discont(w,x):fitfunc
wave w
variable x

//w[0]=L
//w[1] = y0
//w[2] = A
//w[3] = k

if(x<w[0])
   return 0
else
  return w[1]+w[2]*exp(-w[3]*x)
endif
End
andyfaff wrote:
This should work. You may want to hold w[0] if you know what the lag time is.


I might add that if w[0] is unknown, and you want to fit it, you will need to create an epsilon wave and set the value of epsilon[0] to something larger than the X spacing of the data. An epsilon wave sets the differencing interval used in computing numeric derivatives of chi-square with respect to the data. If a derivative is zero, it causes a singular matrix error. If the differencing interval for L is less than a single data point, then there will be no change in chi-square.

Chances are you can set L simply by inspecting the data set. Then you can hold it. That will make the fit much more trouble-free.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Another way to get around the singular matrix problem would be to use the Gencurvefit XOP, which doesn't use a gradient based technique to fit the data.