Fitting a charge like curve

37 Views Asked by At

I am thinking of fitting a charge like curve on a few data points of a time series. By charge curve I mean that I expect my time serie to be increasing and converging toward a limit value.

I thought of the classic condensator charge function:

y = y0 + (lim - y0)*(1 - exp(-t/T))

Where my parameters to fit would be T and lim. However I can't seem to wrangle the equation in such a way that it comes down to a linear equation.

I thought of a+ b/(x + c), with c = (y0 - a)/b, but again, wrangling up things seems complicated.

I came up with y = (lim - y0)*exp(-T/t) + y0, but I wonder if there is any other model to fit.

Finally I could try an optimization (e.g. Least Square) with one of the first 2 (or both), but I wonder if there is anything easier.

1

There are 1 best solutions below

0
On

For conveniency, I shall change you notations and write the model as $$y=a +(b-a) (1-e^{-c t})$$ where $a=y_0$, $b=\text{lim}$ and $c=\frac 1T$. The unknowns parameters are $b$ and $c$.

As you noticed, this is a very nonlinear model and you will need good estimates to start the nonlinear regression.

To do that quite easily, asssign to $b$ a value (larger than the maximum of the $y_i$'). It is probable that, looking at the graph, you could visually have a good idea of the horizontal asymptote. So, rewriting for this value of $b$,we can change to model writing

$$e^{-ct}=\frac{b -y}{b-a}\implies c t=\log\left(\frac{b -a}{b-y} \right)$$ So, define for the time being $$z_i=\log\left(\frac{b -a}{b-y_i} \right)$$which makes the model to be $z=ct$ which is simple since $$c=\frac{\sum_{i=1}^n t_i z_i}{\sum_{i=1}^n t_i^2}$$ For this value of $c$, compute the $z_i^{calc}$ and from them the $y_i^{calc}$ according to $$y_i^{calc}=(a-b)\,e^{-z_i^{calc}} +b$$ and now $$SSQ(b)=\sum_{i=1}^n (y_i^{calc}-y_i)^2$$

Compute $SSQ(b)$ for a series of values of $b$ until you see more or less a minimum (you can even zooming). For this "best" $b$, you also know the corresonding $c$.

Use this values and perform the non linear regression. All of that is simple and can be done in a very short time with Excel or any other tool.