2

I've got a dataset with a clear logarithmic relationship, however, I need the equation that describes the relationship.

I think that it will take the form $f(x) = a \cdot log_b(x) + c$.

I would like to know what the best method would be of finding the coefficients $a, b$ & $c$ ($b$ being the logarithm's base).

I found this answer which is close to what I need but not quite the same as it is specifically using base $e$ whereas I don't know what my base is:

How to fit logarithmic curve to data, in the least squares sense?

TheHolyJoker
  • 2,040
  • What do you mean you don't your base? The base shouldn't matter: any logarithm can be expressed in any base, because of the change of base formula. The natural exponent ($e$) is just a good default option; TLDR: the base in the regression shouldn't matter. – Shon Verch Dec 12 '19 at 13:19
  • In fact $\log_bx=\ln x/\ln b$, so the choice of $b$ can be absorbed into $a$. –  Dec 12 '19 at 14:13

1 Answers1

2

This is probably obvious to most people but took me a bit of head scratching to get straighten out what the comments meant so thought I'd work it through explicitly below. Also needed an answer so that I could mark as solved.

In fact $log_bx = \frac{lnx}{lnb}$, so the choice of $b$ can be absorbed into $a$. – Rahul Dec 12 at 14:13


$f(x) = a \cdot log_b(x) + c$

$log_b(x) = \frac{ln(x)}{ln(b)}$

$f(x) = a \cdot \frac{ln(x)}{ln(b)} + c$ = $\frac{a}{ln(b)} \cdot ln(x) + c$

A = $\frac{a}{ln(b)}$

B = c

$f(x) = A \cdot ln(x) + B$


And the rest of the solution can be found here:

How to fit logarithmic curve to data, in the least squares sense?