1
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ Check this prior thread or this other for simultaneous fitting. $\endgroup$ Feb 8, 2016 at 18:21
  • 4
    $\begingroup$ 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). >> $\endgroup$ Feb 8, 2016 at 18:44

1 Answer 1

5
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ 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] $\endgroup$
    – george2079
    Feb 9, 2016 at 15:57

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