Hi,
I have problems to get a reasonable IntegralError for some fits and fit functions. Sometimes the function seems to return reasonable numbers, sometimes it returns crap. Here is a code example
void testinterr(bool add=false)
{
gRandom->SetSeed(1);
TH1F *h1 = new TH1F("h1","",100,0.98,1.1);
TF1 *f1 = new TF1("f1","[0]*(x>[1])*(x<[3])*(abs(x-[1]))^[2]*(abs(x-[3]))^[4]",0.98,1.1);
f1->SetParameters(10,0.988,0.5,4,2);
h1->FillRandom("f1",10000);
if (add) {
// with these lines in I get Err = 0
f1->SetParameters(10,0.988,0.8,4,2);
h1->FillRandom("f1",3000);
}
h1->Fit("f1","");
TFitResultPtr pfit = h1->Fit("f1","ms");
double n = f1->Integral(1,1.04);
double dn = f1->IntegralError(1,1.04,pfit->GetParams(), pfit->GetCovarianceMatrix().GetMatrixArray());
cout <<n<<" +- "<<dn<<endl;
}
which gives in my case
root [0] .x testinterr.C(0)
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
FCN=64.9812 FROM HESSE STATUS=NOT POSDEF 33 CALLS 336 TOTAL
EDM=4.81713e-08 STRATEGY= 1 ERR MATRIX NOT POS-DEF
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 2.50059e+00 3.25677e-01 9.95067e-05 -2.09580e-03
2 p1 9.87771e-01 3.57446e-05 4.71006e-07 4.91257e+00
3 p2 4.78138e-01 1.44689e-02 1.35182e-05 1.60692e-02
4 p3 3.63503e+02 5.37157e+01 1.63897e-02 -8.33421e-06
5 p4 8.80006e-01 2.22002e-02 6.75196e-06 -3.26871e-02
3.39934 +- 0.0443608
and
root [1] .x testinterr.C(1)
Warning in <TROOT::Append>: Replacing existing TH1: h1 (Potential memory leak).
Warning in <Fit>: Abnormal termination of minimization.
FCN=80.6087 FROM MIGRAD STATUS=CALL LIMIT 1631 CALLS 1632 TOTAL
EDM=0.000483126 STRATEGY= 1 ERROR MATRIX UNCERTAINTY 39.0 per cent
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 7.19014e+00 2.31244e+00 4.12053e-02 -4.37627e-01
2 p1 9.87753e-01 5.17554e-05 4.37660e-07 1.18930e+02
3 p2 5.47573e-01 1.46104e-02 5.23733e-05 9.36261e+00
4 p3 1.35637e+01 5.08601e+00 8.97266e-02 -4.60816e-01
5 p4 1.81669e+00 4.26753e-01 -7.46502e-03 -7.92311e+00
4.26503 +- 0
The first error looks fine I guess, but in the second case, err = 0 is obviously wrong. The fit output prints “Warning in <Fit>: Abnormal termination of minimization.” in the second case, perhaps this is connected to the problem.
Does somebody know what’s going wrong, and how to fix it? I would like to use this rather complicated function to describe a phase space border background shape (of a phi(1020)) and have no good idea how to alternatively estimate the error of the integral. Other functions (except polynomials as it seems) show a similar behavior anyways, so replacing the function didn’t help until now. Polys unfortunately don’t fit sufficiently well.
Best and thanks,
Klaus
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.24-04
Platform: Not Provided
Compiler: Not Provided