Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have 4 data points. t is in minutes, and y is radioactive counts per minute. When I input the following lines:

data = {{90., 140075.}, {120., 96018.}, {150., 73003.}, {180., 36980.}};
model = a*Exp[-k*t];
fit = FindFit[data, model, {a, k}, t]

the output given is:

{a -> 64.6435, k -> 0.29285}

This is clearly not correct. The parameter 'a' should be somewhere around 530000 (as per Excel's fitted equation). What's happening here, and how can I fix this? I'm surprised a bit. This is a simple exponential fit. What am I doing wrong?

share|improve this question
Try providing a reasonable initial guess: fit = FindFit[data, model, {{a, Last@Mean[data]}, {k, 1/First@Mean[data]}}, t] –  Rahul Jul 12 '14 at 5:50

3 Answers 3

fit = FindFit[data, model, {a, k}, t, Method -> "NMinimize"]
share|improve this answer

As has been already commented you can specify Method or specify approximate parameter values as per Rahul Narain's comment.

You can also use NonlinearModelFit,e.g.:

nlm=NonlinearModelFit[data, {a Exp[- k t]}, {{a, 53000}, {k, 1/100}}, t]

yields :448761. E^(-0.0128453 t)

Visualizing fit:

Plot[nlm[t], {t, 80, 200}, 
 Epilog -> {Red, PointSize[0.02], Point[data]}, PlotRange -> All]

enter image description here

For this specific problem you could transform data and use LinearModelFit and back transform.

tdata = {#1, Log@#2} & @@@ data
lm = LinearModelFit[tdata, {1, t}, t]
btf = Exp[Normal@lm]
{Exp[#1], #2} & @@ lm["BestFitParameters"]

The last expression yielding back transformed parameters: {530142., -0.0142315}

Plot[btf, {t, 90, 200}, Epilog -> {Red, PointSize[0.02], Point[data]},
  PlotRange -> All, AxesOrigin -> {90, 19000}]

enter image description here

There are a lot of related (perhaps duplicate) questions that provide valuable information. I suggest looking at them also.

share|improve this answer
Is the only difference between FindFit and NonlinearModelFit the fact that the latter provides more statistical information, or is there anything deeper than that? –  Rahul Jul 12 '14 at 6:53
@RahulNarain I do not know the answer to the specific question. I frequently use NonlinearModelFit to look at quantification of model fit, reasonableness of assumptions, look for systematic error in residuals...as well as the "glorious p-values"...there seems to be a lot of intersection...both seems to accept methods... –  ubpdqn Jul 12 '14 at 7:40
@RahulNarain I believe that FindFit minimizes, e.g. the least squares error, whereas NonlinearModelFit maximizes the value of the parameter values with respect to a likelihood function. –  Eric Brown Jul 12 '14 at 14:18

You may be interested to know that we are working on a FindSimpleFit function that is intended to automate the finding of many common classes of curve, exponentials obviously included. This is similar to what Wolfram|Alpha Pro currently does when you upload a dataset that looks like a timeseries or scatterplot. Automation for the win!

share|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.