I am trying to fit the following bivariate data set using the FindFit function:

 data = {{0.017, 1.091}, {0.034, 1.054}, {0.051, 1.130}, {0.068, 
   1.226}, {0.085, 1.184}, {0.102, 1.307}, {0.119, 1.250}, {0.136, 
   1.326}, {0.153, 1.324}, {0.17, 1.336}, {0.187, 1.314}, {0.204, 
   1.382}, {0.221, 1.333}, {0.238, 1.402}, {0.255, 1.316}, {0.272, 
   1.474}, {0.289, 1.382}, {0.306, 1.308}}

However, when I use the function I get an error:

FindFit[data, {a + b*Exp[-k*x]}, {a, b, k}, {x, y}]

FindFit::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations. >>

Any help on how to fix this expression would be appreciated.

closed as off-topic by Sjoerd C. de Vries, MarcoB, user9660, m_goldberg, Öskå Feb 9 '16 at 19:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Sjoerd C. de Vries, MarcoB, Community, m_goldberg, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Check this prior thread or this other for simultaneous fitting. – Daniel Lichtblau Feb 8 '16 at 18:21
  • 4
    Are you sure about the {x, y} argument? You get the above warning only when you use {x}. Using the function as above yields another message: FindFit::fitc: Number of coordinates (1) is not equal to the number of variables (2). >> – Sjoerd C. de Vries Feb 8 '16 at 18:44
up vote 5 down vote accepted

I wonder if I misunderstand your problem, but it seems to me that perhaps your exponential decay model is inappropriate to your data:

data = {{0.017, 1.091}, {0.034, 1.054}, {0.051, 1.130}, {0.068, 1.226}, {0.085, 1.184},
        {0.102, 1.307}, {0.119, 1.250}, {0.136, 1.326}, {0.153, 1.324}, {0.17, 1.336},
        {0.187, 1.314}, {0.204, 1.382}, {0.221, 1.333}, {0.238, 1.402}, {0.255, 1.316},
        {0.272, 1.474}, {0.289, 1.382}, {0.306, 1.308}};

ListPlot[data, PlotRange -> All]

Mathematica graphics


Perhaps an exponential rise to max model such as $a\ (1-b\ e^{-kx})$ would be more appropriate:

fit = FindFit[data, a (1 - b Exp[-k*x]), {a, b, k}, x]

(* Out: {a -> 1.3988, b -> 0.301228, k -> 10.6606} *)

This seems to reproduce your data better:

Show[{
  ListPlot[data, PlotStyle -> {PointSize[0.015], Red}],
  Plot[a (1 - b Exp[-k*x]) /. fit, {x, 0, 0.35}]},
  PlotRange -> All
]

Mathematica graphics

  • note the original expression (after fixing syntax issues) gives this same result if you supply a good initial guess for k : FindFit[data, a + b*Exp[-k*x], {a, b, {k, 20}}, x] – george2079 Feb 9 '16 at 15:57

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