Error on Integral of function not Resulting From Fit

Hi All,

I’m trying to compute the error of an integral which has values in its integrand with known uncertainties. In particular, this is an integral of a function which is not the result of a fit. Consider, for example, a Gaussian defined in the code below with an amplitude, mean, and width with uncertainties.

I’ve attempted to do this with TF1::IntegralError() which seems like it should be capable of this, but it complains:
“Error in TF1Helper::IntegralError: No existing fitter can be used for computing the integral error”.

Am I doing something wrong here?

Thanks,
Chris

//How to find the error on an integral of a function
//that isn't the result of a fit

void integralError(){

  TF1 *f1 = new TF1("f1","gaus(0)",-10,10);

  f1->SetParameters(100,0,2);
  f1->SetParError(0,10);
  f1->SetParError(1,.6);
  f1->SetParError(2, .3);

  cout <<"Integral: " <<f1->Integral(-10,10) <<endl
       <<"Integral Error: " <<f1->IntegralError(-10,10);

}

Read the notes about the “covmat” parameter in the TF1::IntegralError method description.

Okay…thanks for making me read that again. When I was reading that late last night somehow I concluded that the parameter errors were automatically used and that entering a covariance matrix was optional. Now I see that if you don’t supply your own covariance matrix it defaults to the last fit that the function was used in. Since I’m not using this function to perform a fit, there was no covariance matrix…and thus the error message.

In the code below I have supplied the parameter errors and a null covariance matrix. I get a number for the integral error rather than a error message, but the number is not what I expect it to be - it returns an integral error of 0. I expect this gaussian to have an error of 36.05 by old school pencil and paper propagation of errors.

[code]//How to find the error on an integral of a function
//that isn’t the result of a fit

void integralError(){

TF1 *f1 = new TF1(“f1”,“gaus(0)”,-10,10);

f1->SetParameters(100,0,2);
f1->SetParError(0,10);
f1->SetParError(1,.6);
f1->SetParError(2, .3);

cout <<"Number of Parameters: " <GetNpar();

Double_t *parErrors = f1->GetParErrors();

TMatrixD covMatrix(3,3);
for (Int_t i=0; i<3; i++){
for (Int_t j=0; j<3; j++){
covMatrix[i][j] = 0.0;
}
}

covMatrix.Print();

cout <<"Integral: " <Integral(-10,10) <<endl
<<"Integral Error: " <IntegralError(-10,10,parErrors,covMatrix.GetMatrixArray())
<<endl;

}[/code]

I’m not sure now what TF1::GetParError really returns, but assuming that it’s simply the “sigma” of the distribution (if it’s not the “sigma”, then you need to “scale” it to “sigma” in the equation below), I would try something like: covMatrix[i][j] = (i == j ? (parErrors[i] * parErrors[i]) : 0.0);
Note that for a “gaussian” you should expect a STRONG (anti-)correlation between its fitted “amplitude” and its fitted “width” (which means that some off-diagonal “covMatrix” elements should be BIG, too).

See:
Wolfram MathWorld - Covariance
Wolfram MathWorld - Variance