Practical Curve Fitting

       Spectra frequently have peaks containing 1 million counts at one energy and 10 counts at another energy.  The relative error on a million-count peak obeying Poisson statistics is while those on a 100- count peak is.  This means that a constant that lowers the relative error of the million count peak is contributes 100 times as much to lowering the weighted c2 as does a constant with the same relative effect in the 100 count region.  Furthermore since the spectrum is viewed on a logarithmic scale, so that both peaks can be seen at the same time, these improvements in the high count peaks are frequently not visible on the plots, while the errors in the low count region are all too obvious.  The presence of this highly accurate data introduces a large number of local minima as the constants fit well one or another feature almost invisible graphically.

Local minima are especially a problem for the Newton Raphson method, owing to the fact that it finds extrema, rather than the global minimum.

       The solution is to make a weighted least squares fit in which the error estimates on the point are determined by the curve fit problem as much as by Poisson statistics.  In particular the error estimate for each data point is taken to be .  The first part of the maximum is the Poisson error of the data point and the second is the curve fitting error representing the fact that with a given number of constants, the data should only be fitted to a limited percentage accuracy. 

In practice the constant b can be determined iteratively. The value of c2 is given by

While the desired value is

       The approximations are accurate in the case that a few f's with very small Poisson standard deviations dominate the sums.  The c2 becomes independent of b as the fit improves.  The value of L works well between 1 and 10 for complete fits and works best at about 100 when outlier removal is desired.