Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a noisy data set (the grey line in the graph below) that corresponds roughly to $y=m(1-2^{-x/k})$ where m and k are unknown constants.

How can I determine the best-fit value of m and k?

enter image description here

I can get an approximate value for k by guessing m and then doing linear regression on $-\log_2(1-y/m)$... by this I estimate m=0.96 and k=1000 (see red and blue dotted lines above), but is there a more systematic way?

Thanks in advance.

share|cite|improve this question
up vote 4 down vote accepted

Why not do nonlinear least-squares via Levenberg-Marquardt instead of futzing with linearizations? There is the lsqnonlin() function available in MATLAB via the Optimization Toolbox. You will need to figure out good starting values for $m$ and $k$, though that LM can polish to a (hopefully) adequate answer.

share|cite|improve this answer
Thanks for this, I hadn't come across lsqnonlin() before... I'll see if I can make it work. – Richard Inglis Sep 3 '11 at 15:05

I made this tutorial article about linear and nonlinear least-squares methods.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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