[Math] Fitting an exponential function to data

MATLABregressionstatistics

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.

Best Answer

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.

Related Question