Find a model for exponential growth and decay.

26 views
Skip to first unread message

Peter Sjöblom

unread,
Oct 29, 2024, 11:13:17 AM10/29/24
to lmfit-py
Hi 
I have a large set of measured electrical pulses originating from clouds of electrons hitting a wire. Another way of describing the data is to say voltage pulses from a delay line detector at a synchrotron facility. They can be described as a multiplication of exponential growth followed by exponential decay. 

The built in ExponentialModel with Ae^(-x/T2) is exactly the decay part Im looking for, but the exponential growth, Ae^(-T1/x) I simply can not find even though I would regard it as basic function. My conclusion is that it does indeed exist and I humbly as for a pointer in the correct direction. I expect to be able to combine the two models, as outlined in the excellent support pages. 

Simultaneously, why not consider expanding the peak-like build in models with one 

A*L*np.exp(-T1/(t-ts)-(t-ts)/T2) 

where 
A is amplitude
L is lambda is e^(2*sqrt(T1/T2))
ts is start of pulse or offset 
the peak is located at t=sqrt(T1*T2)

For background look at e.g reference LONG-LAG, WIDE-PULSE GAMMA-RAY BURSTS
J. P. Norris, J. T. Bonnell, D. Kazanas, J. D. Scargle, J. Hakkila, and T. W. Giblin Received 2004 November 29; accepted 2005 March 8
particularly the appendix A.

Even though not the sam physical 

BR
Peter Sjöblom



Matt Newville

unread,
Oct 29, 2024, 11:49:55 AM10/29/24
to lmfi...@googlegroups.com
Hi Peter,

I think the reason we don't have that as a built-in model is because no one has proposed it yet.   It seems like it would not be hard to write that as a model function and just use it without it being a built-in Model. 

My questions would be 
a) whether that seems generally useful (at least in comparison to the other built-in models)?, and
b) if it would benefit from having derived parameters, parameter hints, and a  "guess()" method?

If either of those is true, and if you're willing to make a pull request, I would not be opposed to adding that.


--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lmfit-py+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lmfit-py/7c3a2c4d-ab21-4818-9e28-015ee4f8746cn%40googlegroups.com.


--
--Matt Newville <newville at cars.uchicago.edu630-327-7411

Erik M

unread,
Oct 30, 2024, 4:35:28 AM10/30/24
to lmfit-py
Hi Peter,

As Matt pointed out, rather than than trying to combine two ExponentialModel instances (in a denominator?), the easiest way to express your model is probably by defining it as a python function where the time-parameter is named x, and then pass it to the Model-class, as on https://lmfit.github.io/lmfit-py/model.html. \

If you want to make your own subclass of Model to also allow features like .guess() and contribute it to the package, I would just like to point out that in other fields, "exponential growth" would be of the form exp(t/T1) rather than the form exp(-T1/t) which you and the cited Norris et al. article uses. On page 326 they write "The effects of T1 and T2 on the pulse amplitude are not completely intuitive—they are not respectively rise and decay constants—since their influence arises as the combined exponential in the denominator, with both terms operating across the pulse’s duration." As far as I can tell without really reading the article, they chose this ad-hoc equation because it's simple to evaluate and can fit the data. Not based on a rigorous modeling of differential equations.

In chemistry (and certainly other situations), there's also another way to get increasing signals involving exponentials, by taking the difference between two terms of the form exp(-t/T) with different time-constants T: The term "rate equations" describes the coupled equations for how several signals (e.g. sample concentrations) rise and/or decay over time. If you have a sequential reaction where substance A turns into substance B and then eventually decays into substance C, and the rate for A-->B is higher than the rate for B-->C, then you'll get a curve shape for the B-signal which initially rises, then reaches a peak and then decays, as illustrated here https://demonstrations.wolfram.com/ConsecutiveExponentialDecay/ .  To get something starting smoothly, like your gamma-pulse model, maybe the C-term's curve wouldn't be too bad, but you'd need a decay to a D-state to make the C-curve go down again so this is not as easy as your cited equation. The rate equation system and solution for A-->B-->C is given at https://en.wikipedia.org/wiki/Rate_equation#Consecutive_reactions and we can see that the B-curve's equation contains a term with (exp(-k1*t) - exp(-k2*t)) which we can write as  (exp(-t/T1) - exp(-t/T2)) by converting from rate k to lifetime or inverse rate T = 1/k. If one also wants to convolute the signal with a Gaussian for finite time resolution, one can replace each exp() term with the ExponentialGaussianModel of lmfit. But it's parametrization is very different (probably not written for time-domain signals), so I have made my own class that uses a function with the signature expgaussian_t(t, height, t_0, FWHM, tau, bg=0) instead. I guess I should get around to making a pull request to offer this to the community.

In conclusion, I just wanted to point out that there are apparently at least three kinds of expressions where "growth" is modelled differently using exponentials, so if a built-in lmfit model is added, it should have a sufficiently long/precise name to not be mistaken for one of the other expressions.

Best regards
Erik
Reply all
Reply to author
Forward
0 new messages