# Is there a curve fitting algorithm that focuses on fitting one part of the curve well rather than trying to make a good general fit?

One use case for this would be multi-exponential decay fitting, I'm talking about functions of the type

$\displaystyle f(t)=\sum_i^N a_i \cdot e^{-t/\tau_i}$

It would be awesome to have a fit algorithm that basically performs a mono-exponential fit, but instead of returning the $a_{Fit}$ and $\tau_{Fit}$ that minimize the sum of the squares of the residuals, it could return a pair of lifetime and amplitude that is actually present in the multi-exponential decay, for example $a_1$ and $\tau_1$.

One very rudimentary idea on how one could go about such an algorithm would be to try and minimize the sum a step function of the residuals:

$$r_i=y_i-f(x_i,\beta) \\ s_i=\left\{ \begin{array}{lr} 0 & r_i < R\\ 1 & r_i\geq R \end{array} \right. \\ \displaystyle S=\sum_i^Ns_i$$ Where $S$ is the sum to be minimized, $s_i$ is the step function at the point $x_i$, $r_i$ are the residuals, $(x_i,y_i)$ the data pairs, $f$ the fit function and $\beta$ its parameters. Minimizing this sum would lead to a fit algorithm that tries to get as many points fit to the accuracy provided by $R$ (in the step function) as possible. Now this is just something I came up with quickly to explain what sort of algorithm I'm looking for. Does something like that exist?

• How could the fit know what values are really there as opposed to fitted values? If you let $N \gt 1$ it will be fitting to a sum of exponentials. This is known to be difficult because all the exponentials look a lot like each other if the time constants are close. Your proposed error function can't tell the difference between errors that are $0$ and $\frac R2$, so will provide a lot less data to the fitter. – Ross Millikan Jul 12 '18 at 15:06
• @RossMillikan I know, if my idea was amazing I wouldn't have to post here asking whether a better option exists. This was just for the purpose of demonstrating what kind of behavior I roughly want. I guess the first improvement would be to have something like $s_i=r_i^2$ for $r_i<R$ and $s_i=R^2$ otherwise. And yes I know that for this problem closely spaced time constants are sometimes impossible to distinguish in the data, but that problem exists for regular least squares fitting, too. – Keno Jul 12 '18 at 15:13
• Nevermind that idea above doesn't work. – Keno Jul 12 '18 at 15:19
• You might be interested in robust regression. Here are some nice slides by P. Breheny on the topic; note especially slides 3 and 7. – Rahul Jul 12 '18 at 16:02
• @Rahul Amazing, this looks exactly like what I want, thank you! Sometimes it just needs a key word to be able to find something on the internet. – Keno Jul 13 '18 at 9:42