# Fitting data with the sum of two exponentials

I want to fit my data as the sum of two exponential along with the condition a + b = 1; How I can introduce the constraint into my model.

data =
{{0., 100.}, {0.02, 81.87}, {0.04, 67.03}, {0.06, 54.88},
{0.08, 44.93}, {0.1, 36.76}};

model = a Exp[-k1 t] + b Exp[-k2 t];

fit = FindFit[data, model, {a, k1, b, k2}, t]


Since a+b=1, then b=1-a and it seems we can do what you are asking for thus:

data = {{0.,100.},{0.02,81.87},{0.04,67.03},{0.06,54.88},{0.08,44.93},{0.1,36.76}};
model = a Exp[-k1 t] + (1 - a) Exp[-k2 t];
fit = FindFit[data, model, {a, k1, k2}, t]


which gives us {a -> 100.039, k1 -> 10.0085, k2 -> 423.019}

Show[ListPlot[data], Plot[model /. fit, {t, 0, .1}]]


The left hand edge of that graph makes sense because when t=0 your model becomes a Exp[0]+(1-a) Exp[0]=a+(1-a)=1.

But you seem to get a much better fit with

model2 = a Exp[-k1 t];
fit = FindFit[data, model2, {a, k1}, t]


which gives us {a -> 100.004, k1 -> 10.0033}

• after normalization can't we put a+b=1?? Commented Jun 21, 2017 at 10:10
• How to get best fit parameter after that?? like R^2 value etc. Commented Jun 21, 2017 at 10:30
• @Anita : Use NonlinearModelFit instead of FindFit, then e.g. fit["RSquared"] to give properties of the fit. Commented Jun 21, 2017 at 15:11