Hi,
I am working with some data that I want to fit using a piecewise function that is one value before time = t' and at time t' it adds a constant term + an exponential decay.
So far I have been fitting using the following defined function:
def function_single(t, baseline, A, B, tau, tprime):
result = baseline + np.heaviside(t-tprime, 1)*(A + B*np.exp(-(t-tprime)/tau))
return result
and on most occasions it works fine, but occasionally I get an error:
ValueError: The input contains nan values
I think the problem might be that it runs into under/overflow issues, so I thought maybe it would be a good idea to make a composite model where I define a model like
Model = Exponential + StepModel
as these are the built-in functions, but I can't figure out how to make the exponential function have the form B*exp(|t-t'|/tau) where it is 0 for t-t' < 0.
Any suggestions or ideas on how to fit a function like this in a smarter way would be very welcome.
Thank you a lot!!