15

If I have a collection of data points that follow an exponential curve relationship, how can I manually construct the equation that defines the best-fit exponential curve for the data?

Nakano
  • 655

3 Answers3

11

I assume you are looking for a curve of the form $y=Ae^{kx}$.

For all your data points $(x_i,y_i)$, compute $w_i=\ln(y_i)$.

Find in the usual way constants $a,b$ such that the line $w=a+bx$ is a line of best fit to the data $(x_i,w_i)$.

Then $e^a$ and $b$ are good estimates for $A$ and $k$ respectively.

Added: "Line of best fit" is a huge subject. We describe a basic method, least squares. The idea is to find numbers $a$ and $b$ which minimize $$\sum_{i=1}^n \left(w_i -(a+bx_i)\right)^2.$$ It turns out that the best $b$ and $a$ are given by the following formulas: $$b=\frac{\sum_{i=1}^n x_iw_i -\frac{1}{n}\left(\sum_{i=1}^n x_i\right)\left(\sum_{i=1}^n w_i\right)}{\sum_{i=1}^n x_i^2 -\frac{1}{n}\left(\sum_{i=1}^n x_i\right)^2}$$ and $$a =\frac{1}{n}\sum_{i=1}^n w_i -\frac{1}{n}b\sum_{i=1}^n x_i,$$ where $b$ is given by the previous formula.

I suggest you look for "least squares" elsewwhere for a more detailed discussion.

André Nicolas
  • 507,029
  • How does one find the constants a and b? – Nakano Apr 04 '13 at 03:44
  • This is a fairly standard technique called linear regression @DoubleBass - just google "line of best fit" and you should find a tutorial :) – muzzlator Apr 04 '13 at 03:45
  • @DoubleBass: I have in added material given the ways to compute the constants $a$ and $b$. even a medium-sized set of data points, like $12$, it is not much fun to do it by hand. There is a lot of software that will do it. Spreadsheets usually have a built in function that will do it. One can also use sophisticated statistic software, such as $R$ (free, but not that easy to use, overkill). – André Nicolas Apr 04 '13 at 04:28
  • What is $m$ in the definition of a? Is it a typo for $n$? – Shirin Nov 14 '13 at 07:06
  • Yes, typo, thanks. – André Nicolas Nov 14 '13 at 07:20
  • @AndréNicolas before asking my question as a separate entry, I want to know if I am asking for the right direction. I am given a model (curve equation). And I had collected a set of data running experiments. I have some knowledge of linear least square fitting, non-linear least square fitting and derivatives. I fitted data to a curve, and derived an equation. But that's so different from the given model. What I really want is to figure out how to fit my data into this given model. I know I sound scattered. Care to guide please? – bonCodigo May 04 '17 at 03:41
  • This will work only if the data doesn't have any non positive values. In case of those they must be handled properly. – Royi Feb 20 '21 at 18:47
  • least squares fit for logarithms will NOT give you the least squares fit for exponential. Some errors will be undervalued, others overvalued – AlexGenkin Nov 08 '23 at 15:47
6

If the function to be fitted is y=A*exp(k*x), then a classical linear regression applied to ln(y)=c+k*x directly leads to the goal. If the function is y=A*exp(k*x)+C, this is more difficult. The usual methods of non linear regression requires a guess of the parameters and iterative computation. A different and non classical method doesn't requires guess nor interation. This traightforward method is shown, with a numerical example, pages 17-18 , in the paper : http://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales

JJacquelin
  • 66,221
  • 3
  • 37
  • 87
  • 1
    Jacquelin's paper here is very direct and clear (if you have at least a little bit of French); there are more general versions of the same approach in JSTOR (1970) and at DOI 10.1002/nme.1620080206 (1974), though you may have to pay for those if your institution doesn't have a subscription. – Norman Gray Feb 06 '15 at 10:25
  • Thank you very much for the information. In fact, the method is not restricted to exponential functions. The exponential case is only one example, as shown in my paper, where several kind of functions are considered in order to show the practical interest of the method in many cases. – JJacquelin Feb 06 '15 at 10:40
  • @JJacquelin Hi, since a lot of time has passed since the initial answer I am wondering whether you have any English version of your paper. – mgus Sep 05 '17 at 02:44
  • @mgus: Since the first edition, some pages were added with more examples. Some were written in English, others in French. The last update is from 2014. Sorry, there is no full English version. – JJacquelin Sep 05 '17 at 05:35
  • What about the case $ C $ is known? Can one still use Linear Least Squares? – Royi Feb 20 '21 at 18:48
  • @ Royi. If C is known let Y=y-C=Aexp(kx) and then Y is known. One can use Linear Least Squares for ln(Y) wrt x. – JJacquelin Feb 20 '21 at 21:01
2

Assuming your functions are of the form $A e^{bx}$, the first step is to take the log of the data and then compute the line of best fit. The slope of the resulting line will give you a good approximation for $b$. The constant term will give you a good approximation to $\log A$. This may not be the exponential of best fit in the true sense because larger errors for large $x$ will be scaled down when taking the log, depends on your needs.

muzzlator
  • 7,325