This
folder examines fits to artificial data using a generalized Fermi function and
its derivative as the fitting function.
1
Generalized Fermi
Function.htm doc Finds
partial derivatives of the Generalized Fermi function and of its derivative
with respect to T.
2
Fitting Dfermi.htm Fits to the derivative of a Fermi function. This also tests the next section, standard
deviation fitting. Of interest is the
fact that the data can collaborate to get a low standard deviation.
3
Standard Deviation
fitting.htm Fits to the standard deviation in the data. The form used here is s2 = max(a + b fA
+ c fA2,d). The
form is required to be positive definite only if d is. Values of fA
and (fi-fA)2
are written out by nlfit.
4
Fitting sdfermi.htm Fit to sum of dfermi. This is a
test of the derivatives in FPOLY.FOR. Data for this fit had a larger error in the
flat region than some generated later.
5
FermiStd.htm Code for using a fit to the
derivative of the Fermi function to find the Fermi function and its standard
deviation.
dfermi.dir,
OUTPUT FILE NAME
DFFERMI.out, DATA SET NAME
1,1, DIMENSION OF X IN F(X), power in ((f-fA)/err)**(2*npow)
R,.0,1,.0, 'R' read data point,err,
'C' err=SQRT(a+b|f|)+c|f|
5 NUMBER OF
CONSTANTS IN POLY
400,2 MIN STEPS, Multi 0 NONE, 1_PPCC+MPH, 2
PPCC+MP, 3 P,PPCC,
.1, INITIAL FR DECREASE DESIRED
1 VARY O FIX
FITTED CONS
ERROR IN CONS --
input error
1 998.5864254374815 +- 20.2 1000 0.003 sigma
1 -8.206805201998250 +- 0.291 -8
0.711 sigma
1 359.2715742295106 +- 1.15 360
0.635 sigma
1 0.9602883783432931 +- 0.878E-01 .9
0.987 sigma
1 0.2392332387917320E-16 +- 0.285E-16
0 0.839 sigma
ended because abs(chb-chl)/chl<1e-9
CHIS=
502.3 FOR 500 DATA POINTS
CHI USED IN
CALCULATING ERRORS IS
502.3
Changing the line with the error to
C,1e-4,1,.0,
'R' read data point,err, 'C' err=SQRT(a+b|f|)+c|f|
FR,CHI,CHB,CHL 0.973151361
269.834422 270.088621 277.540181 Y
FR,CHI,CHB,CHL 0.947023570
267.347523 266.857615 269.834422 N
FR,CHI,CHB,CHL 0.947023570
266.888589 266.865659 267.347523 N
FR,CHI,CHB,CHL 0.947023570
266.887773 266.887755 266.888589 N
FR,CHI,CHB,CHL 0.947023570
266.887770 266.887769 266.887773 N
FR,CHI,CHB,CHL 0.947023570
266.887770 266.887770 266.887770 N
ROBMIN finds no lower values
CHI AT END OF FIT 266.8877696341358000
1
899.9631801507963000 +- 19.0298132302765900 5.24
sigma
1 -7.4634323997976110 +- 0.2665327605582825 2.02 sigma
1
358.6590107052419000 +- 1.0657971020038890 1.26
sigma
1 0.9838298908991070 +- 0.0909048137467139 .93 sigma
1 -2.5162568757545220D-005 +- 0.0007934167455634 0
FINAL CHIT=
266.8877696341358000
CHI/DEG OF FREE 0.5391672113820926
RESULTS IN FILE dfermi2.dir
Note that the chi-square is lower than that using the accurate error estimates. Change the error estimate to
c,1e-4,1,.0, 'R' read data point,err, 'C' err=SQRT(a+b|f|)+c|f|
The lower case c causes f to be calculated using the current set of constants.
FIT
IS BEING MADE TO DATA IN FILE
DFFERMI.out
MULTIPLE PRECISION PPCC and MPSMINV
FR,CHI,CHB,CHL 0.100000000
539.027881 0.100000000+307
0.500000000+307N
FR,CHI,CHB,CHL 0.100000000
467.415233 471.465439 539.027881 N
FR,CHI,CHB,CHL 0.100000000
467.205333 467.205933 467.415233 N
FR,CHI,CHB,CHL 0.100000000
467.204700 467.204731 467.205333 N
FR,CHI,CHB,CHL 0.100000000
467.204690 467.204691 467.204700 N
FR,CHI,CHB,CHL 0.100000000
467.204690 467.204690 467.204690 N
ROBMIN finds no lower values
CHI AT END OF FIT 467.2046895810433000
1
998.2001009817087000 +-
18.9436941072828900
1 -8.1565196388056300 +- 0.2421612739495582
1
359.7812964888203000 +-
0.9250732527738026
1 0.9214996954928953 +- 0.0650145772774638
1 7.7195005742676250D-005 +- 0.0007546439395723
FINAL CHIT=
467.2046895810433000
CHI/DEG OF FREE 0.9438478577394814
RESULTS IN FILE dfermi.dir
Figure 2 The fit comes out in the file fit.dat. I use gplot to plot the data and fit.dat.
It is numerically integrated in sum.for. – see ..\..\Weights\ArtDat\Sum.doc -- This was compiled and linked using the command
Wfl386 sum
Figure 3 Sum of the file dfermi.out
The errors in figure 2 are clearly not random. The errors to the right of the step are a sum of the errors introduced going up the step.
The various doc files describe the code in
detail, the derivatives and a few graphs.
Directions for fitting data
1. First plot your data.
Both of the trial data sets had a single wild point. This destroys any genuine least squares routine. Find these points and remove them.
2. The error is of the form
3. Make a direction file modelled on 1-5.DIR. Note that the error estimate is of the form It is best to fix some of the constants on the first pass.