Get coefficients of a closest logarithmic function to a set of data points

33 Views Asked by At

I have a big set of points (x,y) which I want to interpolate by a function $$y=a\log(bx+c)+d$$ What is the best way to find a,b,c and d?

I tried Levenberg–Marquardt algorithm to iteratively find those coefficients, it works, but it seems like overkill. If there is something better and faster, please suggest it.

1

There are 1 best solutions below

2
On

Assuming that you want to perform a curve fit.

You have $n$ data points$(x_i,y_i)$ and you want to use the model $$y=a\log(bx+c)+d$$ First rewrite it as $$y=a \log(1+\alpha x) + \beta \qquad \quad \text{where}\quad \alpha=\frac b c \quad \text{and}\quad \beta=a \log(c)+d$$

This model is nonlinear only because of $\alpha$. If you give $\alpha$ an arbitray value, $$z_i=\log(1+\alpha x_i) \implies y=a z+\beta$$ and you immediately obtain $a$ and $\beta$ solving for these the normal equations $$\sum_{i=1}^n y_i z_i= a\sum_{i=1}^n z_i^2+\beta \sum_{i=1}^n z_i$$ $$\sum_{i=1}^n y_i = a\sum_{i=1}^n z_i +\beta \,n$$ and then $$\text{SSQ}(\alpha)=\sum_{i=1}^n \big[a\,z_i+\beta-y_i \big]^2$$

Do it for a few values of $\alpha$ until you see more or less a minimum of $\text{SSQ}(\alpha)$ . At this point, you have consistent guesses and you can safely start a nonlinear regression or (why not ?) use Newton-Raphson method or Excel solver.

This should not take more than a couple of minutes.