| 334 |
// |
// |
| 335 |
// Changing the fitting function |
// Changing the fitting function |
| 336 |
// ============================= |
// ============================= |
| 337 |
// By default the fitting function GraphFitChisquare is used. |
// By default a chi2 fitting function is used for fitting the TGraphs's. |
| 338 |
|
// The function is implemented in FitUtil::EvaluateChi2. |
| 339 |
|
// In case of TGraphErrors an effective chi2 is used |
| 340 |
|
// (see TGraphErrors fit in TGraph::Fit) and is implemented in |
| 341 |
|
// FitUtil::EvaluateChi2Effective |
| 342 |
// To specify a User defined fitting function, specify option "U" and |
// To specify a User defined fitting function, specify option "U" and |
| 343 |
// call the following functions: |
// call the following functions: |
| 344 |
// TVirtualFitter::Fitter(mygraph)->SetFCN(MyFittingFunction) |
// TVirtualFitter::Fitter(mygraph)->SetFCN(MyFittingFunction) |
| 345 |
// where MyFittingFunction is of type: |
// where MyFittingFunction is of type: |
| 346 |
// extern void MyFittingFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag); |
// extern void MyFittingFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag); |
| 347 |
// |
// |
| 348 |
// How errors are used in the chisquare function (see TFitter GraphFitChisquare)// Access to the fit results |
// Access to the fit result |
| 349 |
// ============================================ |
// ======================== |
| 350 |
// In case of a TGraphErrors object, ex, the error along x, is projected |
// The function returns a TFitResultPtr which can hold a pointer to a TFitResult object. |
| 351 |
// along the y-direction by calculating the function at the points x-exlow and |
// By default the TFitResultPtr contains only the status of the fit and it converts |
| 352 |
// x+exhigh. |
// automatically to an integer. If the option "S" is instead used, TFitResultPtr contains |
| 353 |
// |
// the TFitResult and behaves as a smart pointer to it. For example one can do: |
| 354 |
// The chisquare is computed as the sum of the quantity below at each point: |
// TFitResultPtr r = graph->Fit("myFunc","S"); |
| 355 |
// |
// TMatrixDSym cov = r->GetCovarianceMatrix(); // to access the covariance matrix |
| 356 |
// (y - f(x))**2 |
// Double_t par0 = r->Parameter(0); // retrieve the value for the parameter 0 |
| 357 |
// ----------------------------------- |
// Double_t err0 = r->ParError(0); // retrieve the error for the parameter 0 |
| 358 |
// ey**2 + ((f(x+exhigh) - f(x-exlow))/2)**2 |
// r->Print("V"); // print full information of fit including covariance matrix |
| 359 |
// |
// r->Write(); // store the result in a file |
| 360 |
// where x and y are the point coordinates. |
// |
| 361 |
// |
// The fit parameters, error and chi2 (but not covariance matrix) can be retrieved also |
| 362 |
// In case the function lies below (above) the data point, ey is ey_low (ey_high). |
// from the fitted function. |
| 363 |
// |
// |
|
// thanks to Andy Haas (haas@yahoo.com) for adding the case with TGraphasymmerrors |
|
|
// University of Washington |
|
|
// |
|
|
// a little different approach to approximating the uncertainty in y because of the |
|
|
// errors in x, is to make it equal the error in x times the slope of the line. |
|
|
// The improvement, compared to the first method (f(x+ exhigh) - f(x-exlow))/2 |
|
|
// is of (error of x)**2 order. This approach is called "effective variance method". |
|
|
// This improvement has been made in version 4.00/08 by Anna Kreshuk. |
|
| 364 |
// |
// |
| 365 |
// Associated functions |
// Associated functions |
| 366 |
// ==================== |
// ==================== |