function ans = mse (M, T, SPOT, b)

  ans = 0;
  for i=1:length(T)
    tT = T(i) - 0;
    y(i,1) = b(1) + (1 - exp (-tT))/tT * (b(2) + b(3)) - b(3) * exp (-tT);

    ans = ans + (y(i,1) - SPOT(i))^2;
  end

end