0
$\begingroup$

Is there any software that will fit a set of 2D points using a logarithmic curve?

I found this, which looks like the formulas I need, but I don't think I have a fancy enough calculator to solve that for me.

WolframAlpha has a LeastSquares[] function, but it looks like it only does linear regressions.

$\endgroup$
  • 3
    $\begingroup$ Is this an example of what you're trying to do: wolframalpha.com/input/… ? $\endgroup$ – Derek Allums Aug 12 '12 at 21:58
  • 2
    $\begingroup$ Any spreadsheet that does linear fits would allow you to take the log of your data before fitting. $\endgroup$ – Ross Millikan Aug 12 '12 at 22:18
  • $\begingroup$ @unit3000-21: That looks exactly like what I was looking for. Didn't know the syntax. Is there a reference somewhere? Anyway, if you made that an answer, I'd accept it. $\endgroup$ – mpen Aug 13 '12 at 0:15
1
$\begingroup$

Here's an example of what you're trying to do in Wolfram Alpha. I think you can do the same thing in Mathematica using similar, or identical notation.

$\endgroup$
1
$\begingroup$

I wouldn't be surprised if Wolfram Alpha is actually doing what Ross suggested: transform the $x$ data by $t_j = \log(x_j)$. Then $y = a \log(b x)$ becomes $y = a t + c$ where $t = \log(x)$ and $c = a \log(b)$. Thus this becomes a linear least-squares problem.

$\endgroup$
  • $\begingroup$ That's a pretty clever way of solving it. $\endgroup$ – mpen Aug 13 '12 at 1:58
  • $\begingroup$ But not necessarily the best method, as the transformation with logarithms will also distort the errors inherent in the data. Most software (yes, even Excel!) allows for nonlinear least-squares fitting; look at their documentation for details. $\endgroup$ – Timmy Turner Aug 13 '12 at 2:07
  • 1
    $\begingroup$ What I would suggest is to use the log transformation to get initial values for the parameters and then use a nonlinear fitter with those as the initial values. My experience with nonlinear fitting is that having good initial parameter values is essential. $\endgroup$ – marty cohen Aug 13 '12 at 2:42
  • $\begingroup$ @marty, that is in fact the proper approach for these things. Use the linearization to obtain good initial values for your NLLS method. $\endgroup$ – J. M. is a poor mathematician Aug 13 '12 at 4:04
  • $\begingroup$ For a standard least-squares in the $y$ direction with the $x$ values considered as exact (which is what is happening here), transforming the $x$ values doesn't cause any "distortion". It really is a linear problem. If you were doing "total least-squares" where errors in both $x$ and $y$ are allowed, you would be right, the problem for a logarithmic fit would be nonlinear. $\endgroup$ – Robert Israel Aug 13 '12 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.