I have a set of datapoints, in this case the temperature of an object adjusting to the environment temperature over time. Because I know these kind of processes take the form of
$$f(x)=Ae^{x/B}+C$$
I think it should be very well possible to predict the near future for this process if I can find these $A$, $B$ and $C$ in the equation. And this is exactly my question.
I know the method of applying linear regression to the log of the data and it works perfectly well, but only to find $A$ and $B$ if the constant $C$ is zero and this is not true in my case. In fact, it's one of the most important things I want to find from the data as it would indicate the environment temperature.
Something tells me that this should be pretty straightforward to do but I just can't get to it.
2026-03-29 22:25:15.1774823115
On
Find parameters for exponential function fitting to datapoints
3.2k Views Asked by user17762 https://math.techqa.club/user/user17762/detail At
3
There are 3 best solutions below
1
On
Okay, I solved my problem for now like so:
- For the whole range in which I expect C do:
- Assume a value for C
- Take the log of the datapoints - C
- Do linear regression over the obtained numbers and by that obtain the best A and B for the given C
- Calculate E, the sum of absolute differences between the points in the dataset and the points that would follow using the obtained A, B and C
- Choose A, B and C for which E was smallest.
To optimize things a bit I first do the process with large steps for C and than repeat it around the minimum with finer steps.
I think there should be better ways but this works well enough for my situation.
This is a non-linear system of equations, so, in general, it is a mess (analytically).
However, as I discovered many years ago, in the case where you have three equally spaced $x$ values, you can solve it directly.
Suppose $y_i = a e^{b x_i} + c$ for $i = 1, 2, 3$ and $x_2-x_1 = x_3-x_2 = d$.
Then $y_2-y_1 = a(e^{b x_2}- e^{b x_1}) = a e^{b x_1}(e^{b(x_2-x_1)}-1) = a e^{b x_1}(e^{bd}-1) $.
Similarly, $y_3-y_2 = a e^{b x_2}(e^{bd}-1) $.
Therefore $\frac{y_3-y_2}{y_2-y_1} = e^{b(x_2-x_1)} = e^{bd} $.
This determines $b$. Either of the equations for $y_{i+1}-y_i$ then determines $a$, and any of the original equations determines $c$.