# Fitting bivariate data using FindFit [closed]

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.

• Check this prior thread or this other for simultaneous fitting. – Daniel Lichtblau Feb 8 '16 at 18:21
• 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

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]

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
]

• 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