The constant CNMPKR is passed to the code CNMFIT.FOR. It determines the ratio of the background width to the foreground width. This is used in the SUBROUTINE DATAC in the bliep.for part of the code. The default size for this ratio is 4.
Data is compressed and
peaks removed in the bliep.for part of the code. This began with the work in ERR.DOC which showed that the correct statistical
weighting for points partly in one region and partly in another is 1/err2
in one region and 1-1/err2
in the second region. The integral of a
Gaussian is
. It is fitted to a pade approximate in Gaussians\nlfit2\Welcome to
nlfit2.htm.
This function is 0.5 at z = 0 and is such that
. Data is fitted by
minimizing

In frequency space the product of the two AiGausses is shown in doc1/A trial d.htm#To_the_frequency_domain to be.
This weighting greatly suppresses frequency components greater than w. This is reinforced by a second “robust” fitting to the same data with the e(t) for these points increased to account for the fact that they are far enough from the fit to be outliers. The inverse of ½ the second derivative matrix is the error matrix for this. Thus this procedure for points spaced more than w apart yields a set of statistically independent points and their standard deviations.
The second part fitting the background involves fitting a spline to these points. The best set of results and hints for how to use bkgfit is in doc1\Aug23-04.doc. A tricky part mentioned in the paper below involves increasing the error on accurate sets of points. The method used here is described in doc1\Alpha for bkg.doc.
The paper described in
http://www.phys.ufl.edu/~coldwell/Const/denton/Denton3.html [. “Robust Fitting of Spectra to Splines with Variable Knots”, R.L. Coldwell, CP475, Application of Accelerators in Research and Industry, edited by J.L. Duggan and I.L Morgan AIP Press, New York (1999)] and the more detailed Stanfit3.html link under hint at the best method for fitting the continuum.
The separation of data into foreground and background is described in #datac. The code fits data at constant CNMPKR in width tapered by AiGauss. That is the weights with a Gaussian fwhm are tapered both sides of a nominal end point such that inside the region the weights are 1-AiGauss and outside they are AiGauss. This makes the errors statistically correct for points that enter into two intervals. The minimium distance between intervals is set such that no point appears in more than two intervals.
The code CNMFIT.FOR calls bliep.for – which contains datac. Five times as many data points are generated as there are terms in a fitting spline. A linear fit to the data points requires ~ 1 second for enough terms ~ 36 to well represent the function. A better fit for enough terms with variable knots ~20 requires on the order of a minute.
.
The partials with respect to cj, dk, and xk are easy to evaluate in this form making it appropriate for fitting the data generated by datac.
08/11/2004 10:36 AM 101,376 doc1/The two forms.htm Detailed derivation of the code SUBROUTINE YPPTOC(X,Y,YPP,C0,C1,C2,C3,D,N) for converting x,y,y” to sum on c and d terms. This code is found in CNMFIT.FOR
08/14/2004 05:03 PM 24,576 doc1/Alpha for bkg.htm The notion that the error should be increased introduced in the general reference above is implemented here by solving for alpha such that 2N=(f-fA)**2/((alpha*f)**2+e2)
The code is
bkgfit.for à bkgfit.wpj Driver and overhead
C#INCLUDE bliep.for
SUBROUTINE DATAC(F,WX,NDAT,FWHMS,IX,FI,WXF,NN,CNMPKR)
doc1/Datac.doc – This is the workhorse code. The fact that AIGAU(0)=0.5 and that AIGAU(-x)+AIGAU(x)=1
Is used to fit the data with a taper equal to a multiple, CNMPKR, of the fwhm. Peaks cannot be fully fitted with this form. The “robust” part of the code increases the error for the positive parts of the fit not fitted. A second pass then produces a background estimate for the data fitted. The minimum separation distance of the peaks fitted is made such that no point is fitted more than twice. Those fitted twice have their weights reduced to account for this fitting.
Note that NN may be returned as less than it was called with. It is limited to the number of data points divided by CNMPKR * fwhm.
C#INCLUDE CNMFIT.for à called by bkgfit – calls datac and outputs data if requested.
C#INCLUDE NLFITSUB.for à On watching this, I changed the distance to Aitkin’s from 5 to 25. The res had to be watched to avoid overflow in converting from a large double precision value to a real.
C#INCLUDE rbrack.for à xml file overhead
C#INCLUDE ROBMIN à sminv used by datac in fitting data sections, used directly by nlfitsub
C#INCLUDE RNUMB à xml file overhead
C#INCLUDE WSYSTEM àwcom\openwsys.for
C#INCLUDE BINDEX à i.o. overhead
C#INCLUDE XMLCOPY à xml file overhead
C#INCLUDE PKPOLY à used by bkgfit to subtract peaks from data
C#INCLUDE SPLINE à from Press
C#INCLUDE SPLINT. à from Press
The display part of the code is described in ..\..\..\unkdis\Welcome.doc.
06/09/2004 12:25 PM 41,472 doc1/Transforms.htm
Gaussians\nlfit2\Welcome to nlfit2.htm
Gaussians\Gauss integral fit.doc Simple curve showing that the Pade approximate fits AiGauss
Gaussians\AiGauss\Welcome to AiGauss.doc