Nonlinear LS regression of $y(x) = a_1e^{b_1x} + a_2e^{b_2x} + \cdots + a_ne^{b_nx}$ and programming

66 Views Asked by At

as my first question I am trying to write a program that determines the coefficients $a_i$ in least-squares-sense of

$$ y(x) = a_1e^{b_1x} + a_2e^{b_2x} + \cdots + a_ne^{b_nx}, $$

where $b_n$ are given constants and usually $n\leq 5$.

The problem is that I can't use Matlab or similar tools, so that I have to code the algorithm for the determination of the cofficients by myself. Unfortunately I have only done linear regression by now and don't really know how to start or if there exists a (fast) proper algorithm that could be used.

So,

  • How should I start and what could be the best method to solve this problem?
  • Is there maybe an open-source implementation of such algorithm that I can use for my problem? (I have to translate it into a very "low-level" scripting-language that only knows for-Loops, conditions and some basic-maths-functions like $\exp(\dots), \ln(\dots),$ etc.

Many thanks in advance and best wishes from Austria, JoDoh

1

There are 1 best solutions below

0
On

$$ y(x_k) = a_1e^{b_1x_k} + a_2e^{b_2x_k} + \cdots + a_ie^{b_ix_k} + \cdots + a_ne^{b_nx_k} \quad\text{for}\quad k=1 \text{ to } N. $$ $N$ is the number of points : measurements $(x_k,y_k)$ . $n$ is the number of exponential terms.

If the parameters $b_i$ are known, this is a simple problem of linear regression :

First, compute all the $X_{i,k}=e^{b_i x_k}$ for the given values of $x$. The initial data $(x_1, \cdots , x_k , \cdots , x_N)$ is transformed into $(X_{1,k}, \cdots , X_{i,k} , \cdots , X_{n,k})$ for $k$=$1$ to $N$. $$ y(X_k) = a_1X_{1,k} + a_2X_{2,k} + \cdots + a_iX_{i,k} + \cdots + a_nX_{n,k}, $$ Second, compute the approximate values of $a_i$ thanks to an usual linear regression. https://en.wikipedia.org/wiki/Linear_regression

So, the problem is solved (insofar the numerical calculus is accurate enough according to possibly too big and/or too small values dues to exponentials).

NOTE :

If the parameters $b_i$ are not known, the problem becomes arduous. This is a problem of non-linear regression which is currently tackled with some iterative algorithm, starting from guessed values of the $b_i$. This is a major difficult in practice, especially if they are several $b_i$.

A method which don't requires initial guess, nor iteration comes from : https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales , pages 71-74. The details of calculus process is given for two exponential terms (copy below). Take care that the notations in the referenced paper are not the same as the above notations introduced by JodaDoh.

The extension for more exponential terms is discussed page 74. On a theoretical viewpoint, the method continue to be valid. But, with more exponential terms, the number of parameter becomes large. So, in cases of scattered data, the process might be not robust enough.

enter image description here