Logo ROOT   6.08/07
Reference Guide
TFitter.cxx
Go to the documentation of this file.
1 // @(#)root/minuit:$Id$
2 // Author: Rene Brun 31/08/99
3 /*************************************************************************
4  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #include "TMinuit.h"
12 #include "TFitter.h"
13 #include "TH1.h"
14 #include "TF1.h"
15 #include "TF2.h"
16 #include "TF3.h"
17 #include "TList.h"
18 #include "TGraph.h"
19 #include "TGraph2D.h"
20 #include "TMultiGraph.h"
21 #include "TMath.h"
22 
23 // extern void H1FitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
24 // extern void H1FitLikelihood(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
25 // extern void GraphFitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
26 // extern void Graph2DFitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
27 // extern void MultiGraphFitChisquare(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
28 extern void F2Fit(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
29 extern void F3Fit(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
30 
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 ///*-*-*-*-*-*-*-*-*-*-*default constructor*-*-*-*-*-*-*-*-*-*-*-*-*
35 ///*-* ===================
36 
38 {
39  fMinuit = new TMinuit(maxpar);
40  fNlog = 0;
41  fSumLog = 0;
42  fCovar = 0;
43  SetName("MinuitFitter");
44 }
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 ///*-*-*-*-*-*-*-*-*-*-*default destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
48 ///*-* ==================
49 
51 {
52  if (fCovar) delete [] fCovar;
53  if (fSumLog) delete [] fSumLog;
54  delete fMinuit;
55 }
56 
57 // ////////////////////////////////////////////////////////////////////////////////
58 // /// return a chisquare equivalent
59 
61 {
62  Error("Chisquare","This function is deprecated - use ROOT::Fit::Chisquare class");
63  //Double_t amin = 0;
64  //H1FitChisquare(npar,params,amin,params,1);
65  return TMath::QuietNaN();
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 /// reset the fitter environment
70 
72 {
73  if (fCovar) {delete [] fCovar; fCovar = 0;}
74  fMinuit->mncler();
75 
76  //reset the internal Minuit random generator to its initial state
77  Double_t val = 3;
78  Int_t inseed = 12345;
79  fMinuit->mnrn15(val,inseed);
80 }
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Execute a fitter command;
84 /// command : command string
85 /// args : list of nargs command arguments
86 
87 Int_t TFitter::ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
88 {
89  if (fCovar) {delete [] fCovar; fCovar = 0;}
90  Int_t ierr = 0;
91  fMinuit->mnexcm(command,args,nargs,ierr);
92  return ierr;
93 }
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// Fix parameter ipar.
97 
99 {
100  if (fCovar) {delete [] fCovar; fCovar = 0;}
101  fMinuit->FixParameter(ipar);
102 }
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 ///Computes point-by-point confidence intervals for the fitted function
106 ///Parameters:
107 ///n - number of points
108 ///ndim - dimensions of points
109 ///x - points, at which to compute the intervals, for ndim > 1
110 /// should be in order: (x0,y0, x1, y1, ... xn, yn)
111 ///ci - computed intervals are returned in this array
112 ///cl - confidence level, default=0.95
113 ///NOTE, that the intervals are approximate for nonlinear(in parameters) models
114 
116 {
117  TF1 *f = (TF1*)fUserFunc;
118  Int_t npar = f->GetNumberFreeParameters();
119  Int_t npar_real = f->GetNpar();
120  Double_t *grad = new Double_t[npar_real];
121  Double_t *sum_vector = new Double_t[npar];
122  Bool_t *fixed=0;
123  Double_t al, bl;
124  if (npar_real != npar){
125  fixed = new Bool_t[npar_real];
126  memset(fixed,0,npar_real*sizeof(Bool_t));
127 
128  for (Int_t ipar=0; ipar<npar_real; ipar++){
129  fixed[ipar]=0;
130  f->GetParLimits(ipar,al,bl);
131  if (al*bl != 0 && al >= bl) {
132  //this parameter is fixed
133  fixed[ipar]=1;
134  }
135  }
136  }
137  Double_t c=0;
138 
139  Double_t *matr = GetCovarianceMatrix();
140  if (!matr)
141  return;
142  Double_t t = TMath::StudentQuantile(0.5 + cl/2, f->GetNDF());
143  Double_t chidf = TMath::Sqrt(f->GetChisquare()/f->GetNDF());
144  Int_t igrad, ifree=0;
145  for (Int_t ipoint=0; ipoint<n; ipoint++){
146  c=0;
147  f->GradientPar(x+ndim*ipoint, grad);
148  //multiply the covariance matrix by gradient
149  for (Int_t irow=0; irow<npar; irow++){
150  sum_vector[irow]=0;
151  igrad = 0;
152  for (Int_t icol=0; icol<npar; icol++){
153  igrad = 0;
154  ifree=0;
155  if (fixed) {
156  //find the free parameter #icol
157  while (ifree<icol+1){
158  if (fixed[igrad]==0) ifree++;
159  igrad++;
160  }
161  igrad--;
162  //now the [igrad] element of gradient corresponds to [icol] element of cov.matrix
163  } else {
164  igrad = icol;
165  }
166  sum_vector[irow]+=matr[irow*npar_real+icol]*grad[igrad];
167  }
168  }
169  igrad = 0;
170  for (Int_t i=0; i<npar; i++){
171  igrad = 0; ifree=0;
172  if (fixed) {
173  //find the free parameter #icol
174  while (ifree<i+1){
175  if (fixed[igrad]==0) ifree++;
176  igrad++;
177  }
178  igrad--;
179  } else {
180  igrad = i;
181  }
182  c+=grad[igrad]*sum_vector[i];
183  }
184 
185  c=TMath::Sqrt(c);
186  ci[ipoint]=c*t*chidf;
187  }
188 
189  delete [] grad;
190  delete [] sum_vector;
191  if (fixed)
192  delete [] fixed;
193 }
194 
195 ////////////////////////////////////////////////////////////////////////////////
196 ///Computes confidence intervals at level cl. Default is 0.95
197 ///The TObject parameter can be a TGraphErrors, a TGraph2DErrors or a TH1,2,3.
198 ///For Graphs, confidence intervals are computed for each point,
199 ///the value of the graph at that point is set to the function value at that
200 ///point, and the graph y-errors (or z-errors) are set to the value of
201 ///the confidence interval at that point.
202 ///For Histograms, confidence intervals are computed for each bin center
203 ///The bin content of this bin is then set to the function value at the bin
204 ///center, and the bin error is set to the confidence interval value.
205 ///NOTE: confidence intervals are approximate for nonlinear models!
206 ///
207 ///Allowed combinations:
208 ///Fitted object Passed object
209 ///TGraph TGraphErrors, TH1
210 ///TGraphErrors, AsymmErrors TGraphErrors, TH1
211 ///TH1 TGraphErrors, TH1
212 ///TGraph2D TGraph2DErrors, TH2
213 ///TGraph2DErrors TGraph2DErrors, TH2
214 ///TH2 TGraph2DErrors, TH2
215 ///TH3 TH3
216 
218 {
219  if (obj->InheritsFrom(TGraph::Class())) {
220  TGraph *gr = (TGraph*)obj;
221  if (!gr->GetEY()){
222  Error("GetConfidenceIntervals", "A TGraphErrors should be passed instead of a graph");
223  return;
224  }
226  Error("GetConfidenceIntervals", "A TGraph2DErrors should be passed instead of a graph");
227  return;
228  }
230  if (((TH1*)(fObjectFit))->GetDimension()>1){
231  Error("GetConfidenceIntervals", "A TGraph2DErrors or a TH23 should be passed instead of a graph");
232  return;
233  }
234  }
235  GetConfidenceIntervals(gr->GetN(),1,gr->GetX(), gr->GetEY(), cl);
236  for (Int_t i=0; i<gr->GetN(); i++)
237  gr->SetPoint(i, gr->GetX()[i], ((TF1*)(fUserFunc))->Eval(gr->GetX()[i]));
238  }
239 
240  //TGraph2D/////////////////
241  else if (obj->InheritsFrom(TGraph2D::Class())) {
242  TGraph2D *gr2 = (TGraph2D*)obj;
243  if (!gr2->GetEZ()){
244  Error("GetConfidenceIntervals", "A TGraph2DErrors should be passed instead of a TGraph2D");
245  return;
246  }
248  Error("GetConfidenceIntervals", "A TGraphErrors should be passed instead of a TGraph2D");
249  return;
250  }
252  if (((TH1*)(fObjectFit))->GetDimension()==1){
253  Error("GetConfidenceIntervals", "A TGraphErrors or a TH1 should be passed instead of a graph");
254  return;
255  }
256  }
257  TF2 *f=(TF2*)fUserFunc;
258  Double_t xy[2];
259  Int_t np = gr2->GetN();
260  Int_t npar = f->GetNpar();
261  Double_t *grad = new Double_t[npar];
262  Double_t *sum_vector = new Double_t[npar];
263  Double_t *x = gr2->GetX();
264  Double_t *y = gr2->GetY();
265  Double_t t = TMath::StudentQuantile(0.5 + cl/2, f->GetNDF());
266  Double_t chidf = TMath::Sqrt(f->GetChisquare()/f->GetNDF());
268  Double_t c = 0;
269  for (Int_t ipoint=0; ipoint<np; ipoint++){
270  xy[0]=x[ipoint];
271  xy[1]=y[ipoint];
272  f->GradientPar(xy, grad);
273  for (Int_t irow=0; irow<f->GetNpar(); irow++){
274  sum_vector[irow]=0;
275  for (Int_t icol=0; icol<npar; icol++)
276  sum_vector[irow]+=matr[irow*npar+icol]*grad[icol];
277  }
278  c = 0;
279  for (Int_t i=0; i<npar; i++)
280  c+=grad[i]*sum_vector[i];
281  c=TMath::Sqrt(c);
282  gr2->SetPoint(ipoint, xy[0], xy[1], f->EvalPar(xy));
283  gr2->GetEZ()[ipoint]=c*t*chidf;
284 
285  }
286  delete [] grad;
287  delete [] sum_vector;
288  }
289 
290  //TH1/////////////////////////
291  else if (obj->InheritsFrom(TH1::Class())) {
293  if (((TH1*)obj)->GetDimension()>1){
294  Error("GetConfidenceIntervals", "Fitted graph and passed histogram have different number of dimensions");
295  return;
296  }
297  }
299  if (((TH1*)obj)->GetDimension()!=2){
300  Error("GetConfidenceIntervals", "Fitted graph and passed histogram have different number of dimensions");
301  return;
302  }
303  }
305  if (((TH1*)(fObjectFit))->GetDimension()!=((TH1*)(obj))->GetDimension()){
306  Error("GetConfidenceIntervals", "Fitted and passed histograms have different number of dimensions");
307  return;
308  }
309  }
310 
311 
312  TH1 *hfit = (TH1*)obj;
313  TF1 *f = (TF1*)GetUserFunc();
314  Int_t npar = f->GetNpar();
315  Double_t *grad = new Double_t[npar];
316  Double_t *sum_vector = new Double_t[npar];
317  Double_t x[3];
318 
319  Int_t hxfirst = hfit->GetXaxis()->GetFirst();
320  Int_t hxlast = hfit->GetXaxis()->GetLast();
321  Int_t hyfirst = hfit->GetYaxis()->GetFirst();
322  Int_t hylast = hfit->GetYaxis()->GetLast();
323  Int_t hzfirst = hfit->GetZaxis()->GetFirst();
324  Int_t hzlast = hfit->GetZaxis()->GetLast();
325 
326  TAxis *xaxis = hfit->GetXaxis();
327  TAxis *yaxis = hfit->GetYaxis();
328  TAxis *zaxis = hfit->GetZaxis();
329  Double_t t = TMath::StudentQuantile(0.5 + cl/2, f->GetNDF());
330  Double_t chidf = TMath::Sqrt(f->GetChisquare()/f->GetNDF());
332  Double_t c=0;
333  for (Int_t binz=hzfirst; binz<=hzlast; binz++){
334  x[2]=zaxis->GetBinCenter(binz);
335  for (Int_t biny=hyfirst; biny<=hylast; biny++) {
336  x[1]=yaxis->GetBinCenter(biny);
337  for (Int_t binx=hxfirst; binx<=hxlast; binx++) {
338  x[0]=xaxis->GetBinCenter(binx);
339  f->GradientPar(x, grad);
340  for (Int_t irow=0; irow<npar; irow++){
341  sum_vector[irow]=0;
342  for (Int_t icol=0; icol<npar; icol++)
343  sum_vector[irow]+=matr[irow*npar+icol]*grad[icol];
344  }
345  c = 0;
346  for (Int_t i=0; i<npar; i++)
347  c+=grad[i]*sum_vector[i];
348  c=TMath::Sqrt(c);
349  hfit->SetBinContent(binx, biny, binz, f->EvalPar(x));
350  hfit->SetBinError(binx, biny, binz, c*t*chidf);
351  }
352  }
353  }
354  delete [] grad;
355  delete [] sum_vector;
356  }
357  else {
358  Error("GetConfidenceIntervals", "This object type is not supported");
359  return;
360  }
361 
362 }
363 
364 ////////////////////////////////////////////////////////////////////////////////
365 /// return a pointer to the covariance matrix
366 
368 {
369  if (fCovar) return fCovar;
370  Int_t npars = fMinuit->GetNumPars();
371  ((TFitter*)this)->fCovar = new Double_t[npars*npars];
372  fMinuit->mnemat(fCovar,npars);
373  return fCovar;
374 }
375 
376 ////////////////////////////////////////////////////////////////////////////////
377 /// return element i,j from the covariance matrix
378 
380 {
382  Int_t npars = fMinuit->GetNumPars();
383  if (i < 0 || i >= npars || j < 0 || j >= npars) {
384  Error("GetCovarianceMatrixElement","Illegal arguments i=%d, j=%d",i,j);
385  return 0;
386  }
387  return fCovar[j+npars*i];
388 }
389 
390 ////////////////////////////////////////////////////////////////////////////////
391 /// return current errors for a parameter
392 /// ipar : parameter number
393 /// eplus : upper error
394 /// eminus : lower error
395 /// eparab : parabolic error
396 /// globcc : global correlation coefficient
397 
398 Int_t TFitter::GetErrors(Int_t ipar,Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const
399 {
400 
401  Int_t ierr = 0;
402  fMinuit->mnerrs(ipar, eplus,eminus,eparab,globcc);
403  return ierr;
404 }
405 
406 
407 ////////////////////////////////////////////////////////////////////////////////
408 /// return the total number of parameters (free + fixed)
409 
411 {
412  return fMinuit->fNpar + fMinuit->fNpfix;
413 }
414 
415 ////////////////////////////////////////////////////////////////////////////////
416 /// return the number of free parameters
417 
419 {
420  return fMinuit->fNpar;
421 }
422 
423 
424 ////////////////////////////////////////////////////////////////////////////////
425 /// return error of parameter ipar
426 
428 {
429  Int_t ierr = 0;
430  TString pname;
431  Double_t value,verr,vlow,vhigh;
432 
433  fMinuit->mnpout(ipar, pname,value,verr,vlow,vhigh,ierr);
434  return verr;
435 }
436 
437 
438 ////////////////////////////////////////////////////////////////////////////////
439 /// return current value of parameter ipar
440 
442 {
443  Int_t ierr = 0;
444  TString pname;
445  Double_t value,verr,vlow,vhigh;
446 
447  fMinuit->mnpout(ipar, pname,value,verr,vlow,vhigh,ierr);
448  return value;
449 }
450 
451 ////////////////////////////////////////////////////////////////////////////////
452 /// return current values for a parameter
453 /// ipar : parameter number
454 /// parname : parameter name
455 /// value : initial parameter value
456 /// verr : initial error for this parameter
457 /// vlow : lower value for the parameter
458 /// vhigh : upper value for the parameter
459 /// WARNING! parname must be suitably dimensionned in the calling function.
460 
461 Int_t TFitter::GetParameter(Int_t ipar, char *parname,Double_t &value,Double_t &verr,Double_t &vlow, Double_t &vhigh) const
462 {
463  Int_t ierr = 0;
464  TString pname;
465  fMinuit->mnpout(ipar, pname,value,verr,vlow,vhigh,ierr);
466  strcpy(parname,pname.Data());
467  return ierr;
468 }
469 
470 ////////////////////////////////////////////////////////////////////////////////
471 /// return name of parameter ipar
472 
473 const char *TFitter::GetParName(Int_t ipar) const
474 {
475  if (!fMinuit || ipar < 0 || ipar > fMinuit->fNu) return "";
476  return fMinuit->fCpnam[ipar];
477 }
478 
479 ////////////////////////////////////////////////////////////////////////////////
480 /// return global fit parameters
481 /// amin : chisquare
482 /// edm : estimated distance to minimum
483 /// errdef
484 /// nvpar : number of variable parameters
485 /// nparx : total number of parameters
486 
487 Int_t TFitter::GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const
488 {
489  Int_t ierr = 0;
490  fMinuit->mnstat(amin,edm,errdef,nvpar,nparx,ierr);
491  return ierr;
492 }
493 
494 ////////////////////////////////////////////////////////////////////////////////
495 /// return Sum(log(i) i=0,n
496 /// used by log likelihood fits
497 
499 {
500  if (n < 0) return 0;
501  if (n > fNlog) {
502  if (fSumLog) delete [] fSumLog;
503  fNlog = 2*n+1000;
504  fSumLog = new Double_t[fNlog+1];
505  Double_t fobs = 0;
506  for (Int_t j=0;j<=fNlog;j++) {
507  if (j > 1) fobs += TMath::Log(j);
508  fSumLog[j] = fobs;
509  }
510  }
511  if (fSumLog) return fSumLog[n];
512  return 0;
513 }
514 
515 
516 ////////////////////////////////////////////////////////////////////////////////
517 ///return kTRUE if parameter ipar is fixed, kFALSE othersise)
518 
520 {
521  if (fMinuit->fNiofex[ipar] == 0 ) return kTRUE;
522  return kFALSE;
523 }
524 
525 
526 ////////////////////////////////////////////////////////////////////////////////
527 /// Print fit results
528 
529 void TFitter::PrintResults(Int_t level, Double_t amin) const
530 {
531  fMinuit->mnprin(level,amin);
532 }
533 
534 ////////////////////////////////////////////////////////////////////////////////
535 /// Release parameter ipar.
536 
538 {
539  if (fCovar) {delete [] fCovar; fCovar = 0;}
540  fMinuit->Release(ipar);
541 }
542 
543 ////////////////////////////////////////////////////////////////////////////////
544 /// Specify the address of the fitting algorithm (from the interpreter)
545 
546 void TFitter::SetFCN(void * /*fcn*/)
547 {
548  if (fCovar) {delete [] fCovar; fCovar = 0;}
549 
550  Error("SetFCN", "Not used anymore.");
551 
552  //TVirtualFitter::SetFCN(fcn);
553  //fMinuit->SetFCN(fcn);
554 
555 }
556 
557 ////////////////////////////////////////////////////////////////////////////////
558 /// Specify the address of the fitting algorithm
559 
560 void TFitter::SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t))
561 {
562  if (fCovar) {delete [] fCovar; fCovar = 0;}
564  fMinuit->SetFCN(fcn);
565 }
566 
567 ////////////////////////////////////////////////////////////////////////////////
568 /// ret fit method (chisquare or loglikelihood)
569 
570 void TFitter::SetFitMethod(const char *name)
571 {
572  if (fCovar) {delete [] fCovar; fCovar = 0;}
573  // if (!strcmp(name,"H1FitChisquare")) SetFCN(H1FitChisquare);
574  // if (!strcmp(name,"H1FitLikelihood")) SetFCN(H1FitLikelihood);
575  // if (!strcmp(name,"GraphFitChisquare")) SetFCN(GraphFitChisquare);
576  // if (!strcmp(name,"Graph2DFitChisquare")) SetFCN(Graph2DFitChisquare);
577  // if (!strcmp(name,"MultiGraphFitChisquare")) SetFCN(MultiGraphFitChisquare);
578  if (!strcmp(name,"F2Minimizer")) SetFCN(F2Fit);
579  if (!strcmp(name,"F3Minimizer")) SetFCN(F3Fit);
580 }
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 /// set initial values for a parameter
584 /// ipar : parameter number
585 /// parname : parameter name
586 /// value : initial parameter value
587 /// verr : initial error for this parameter
588 /// vlow : lower value for the parameter
589 /// vhigh : upper value for the parameter
590 
591 Int_t TFitter::SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh)
592 {
593  if (fCovar) {delete [] fCovar; fCovar = 0;}
594  Int_t ierr = 0;
595  fMinuit->mnparm(ipar,parname,value,verr,vlow,vhigh,ierr);
596  return ierr;
597 }
598 
599 
600 
601 ////////////////////////////////////////////////////////////////////////////////
602 
603 void F2Fit(Int_t &/*npar*/, Double_t * /*gin*/, Double_t &f,Double_t *u, Int_t /*flag*/)
604 {
606  TF2 *f2 = (TF2*)fitter->GetObjectFit();
607  f2->InitArgs(u, f2->GetParameters() );
608  f = f2->EvalPar(u);
609 }
610 
611 ////////////////////////////////////////////////////////////////////////////////
612 
613 void F3Fit(Int_t &/*npar*/, Double_t * /*gin*/, Double_t &f,Double_t *u, Int_t /*flag*/)
614 {
616  TF3 *f3 = (TF3*)fitter->GetObjectFit();
617  f3->InitArgs(u, f3->GetParameters() );
618  f = f3->EvalPar(u);
619 }
virtual Bool_t IsFixed(Int_t ipar) const
return kTRUE if parameter ipar is fixed, kFALSE othersise)
Definition: TFitter.cxx:519
virtual void mnstat(Double_t &fmin, Double_t &fedm, Double_t &errdef, Int_t &npari, Int_t &nparx, Int_t &istat)
Returns concerning the current status of the minimization.
Definition: TMinuit.cxx:7660
virtual void mnprin(Int_t inkode, Double_t fval)
Prints the values of the parameters at the time of the call.
Definition: TMinuit.cxx:6328
virtual void PrintResults(Int_t level, Double_t amin) const
Print fit results.
Definition: TFitter.cxx:529
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:444
Implementation in C++ of the Minuit package written by Fred James.
Definition: TMinuit.h:31
virtual Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const
return element i,j from the covariance matrix
Definition: TFitter.cxx:379
Double_t Log(Double_t x)
Definition: TMath.h:526
virtual void mnemat(Double_t *emat, Int_t ndim)
Calculates the external error matrix from the internal matrix.
Definition: TMinuit.cxx:2525
virtual Double_t * GetCovarianceMatrix() const
return a pointer to the covariance matrix
Definition: TFitter.cxx:367
return c
const char Option_t
Definition: RtypesCore.h:62
virtual Int_t GetNumberFreeParameters() const
Return the number of free parameters.
Definition: TF1.cxx:1613
Double_t QuietNaN()
Definition: TMath.h:622
Double_t StudentQuantile(Double_t p, Double_t ndf, Bool_t lower_tail=kTRUE)
Computes quantiles of the Student&#39;s t-distribution 1st argument is the probability, at which the quantile is computed 2nd argument - the number of degrees of freedom of the Student distribution When the 3rd argument lower_tail is kTRUE (default)- the algorithm returns such x0, that P(x < x0)=p upper tail (lower_tail is kFALSE)- the algorithm returns such x0, that P(x > x0)=p the algorithm was taken from G.W.Hill, "Algorithm 396, Student&#39;s t-quantiles" "Communications of the ACM", 13(10), October 1970.
Definition: TMath.cxx:2611
virtual Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const
return current errors for a parameter ipar : parameter number eplus : upper error eminus : lower erro...
Definition: TFitter.cxx:398
virtual Double_t * GetEY() const
Definition: TGraph.h:143
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs)
Execute a fitter command; command : command string args : list of nargs command arguments.
Definition: TFitter.cxx:87
const char * Class
Definition: TXMLSetup.cxx:64
virtual const char * GetParName(Int_t ipar) const
return name of parameter ipar
Definition: TFitter.cxx:473
virtual Int_t FixParameter(Int_t parNo)
fix a parameter
Definition: TMinuit.cxx:836
virtual ~TFitter()
-*-*-*-*-*-*-*-*-*-*default destructor-*-*-*-*-*-*-*-*-*-*-*-*-* *-* ================== ...
Definition: TFitter.cxx:50
virtual Int_t GetNDF() const
Return the number of degrees of freedom in the fit the fNDF parameter has been previously computed du...
Definition: TF1.cxx:1602
virtual void SetFCN(void *fcn) R__DEPRECATED(6
Specify the address of the fitting algorithm (from the interpreter)
Definition: TFitter.cxx:546
Double_t x[n]
Definition: legend1.C:17
int GetDimension(const TH1 *h1)
Definition: HFitImpl.cxx:51
Int_t fNpar
Definition: TMinuit.h:45
virtual void ReleaseParameter(Int_t ipar)
Release parameter ipar.
Definition: TFitter.cxx:537
TObject * fObjectFit
virtual void mnrn15(Double_t &val, Int_t &inseed)
This is a super-portable random number generator.
Definition: TMinuit.cxx:6641
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:464
Double_t * fSumLog
Definition: TFitter.h:35
virtual Int_t GetNumberFreeParameters() const
return the number of free parameters
Definition: TFitter.cxx:418
virtual void SetFCN(void *fcn) R__DEPRECATED(6
To set the address of the minimization objective function.
virtual Double_t * GetEZ() const
Definition: TGraph2D.h:133
virtual void SetBinError(Int_t bin, Double_t error)
See convention for numbering bins in TH1::GetBin.
Definition: TH1.cxx:8309
virtual Double_t GradientPar(Int_t ipar, const Double_t *x, Double_t eps=0.01)
Compute the gradient (derivative) wrt a parameter ipar.
Definition: TF1.cxx:2153
virtual void mnpout(Int_t iuext, TString &chnam, Double_t &val, Double_t &err, Double_t &xlolim, Double_t &xuplim, Int_t &iuint) const
Provides the user with information concerning the current status.
Definition: TMinuit.cxx:6271
TObject * fUserFunc
virtual Double_t GetParameter(Int_t ipar) const
return current value of parameter ipar
Definition: TFitter.cxx:441
Int_t fNpfix
Definition: TMinuit.h:41
Int_t GetLast() const
Return last bin on the axis i.e.
Definition: TAxis.cxx:455
TString * fCpnam
Character to be plotted at the X,Y contour positions.
Definition: TMinuit.h:169
Class to manage histogram axis.
Definition: TAxis.h:36
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
virtual void mncler()
Resets the parameter list to UNDEFINED.
Definition: TMinuit.cxx:1127
virtual void mnparm(Int_t k, TString cnamj, Double_t uk, Double_t wk, Double_t a, Double_t b, Int_t &ierflg)
Implements one parameter definition.
Definition: TMinuit.cxx:5689
A 3-Dim function with parameters.
Definition: TF3.h:30
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:488
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition: TH1.cxx:8323
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:925
Double_t * fCovar
Definition: TFitter.h:34
static TVirtualFitter * GetFitter()
static: return the current Fitter
Int_t GetN() const
Definition: TGraph.h:133
TAxis * GetYaxis()
Definition: TH1.h:325
A 2-Dim function with parameters.
Definition: TF2.h:33
virtual void mnerrs(Int_t number, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &gcc)
Utility routine to get MINOS errors.
Definition: TMinuit.cxx:2602
virtual Double_t Chisquare(Int_t npar, Double_t *params) const
Definition: TFitter.cxx:60
TGraphErrors * gr
Definition: legend1.C:25
Int_t * fNiofex
Definition: TMinuit.h:131
Double_t * GetY() const
Definition: TGraph2D.h:129
Double_t * GetX() const
Definition: TGraph.h:140
Double_t GetChisquare() const
Definition: TF1.h:336
virtual void SetFitMethod(const char *name)
ret fit method (chisquare or loglikelihood)
Definition: TFitter.cxx:570
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
virtual Double_t GetSumLog(Int_t i)
return Sum(log(i) i=0,n used by log likelihood fits
Definition: TFitter.cxx:498
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
Definition: TGraph2D.cxx:1692
double Double_t
Definition: RtypesCore.h:55
void F2Fit(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Definition: TFitter.cxx:603
virtual Double_t GetParError(Int_t ipar) const
return error of parameter ipar
Definition: TFitter.cxx:427
virtual Int_t Release(Int_t parNo)
release a parameter
Definition: TMinuit.cxx:903
virtual void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95)
Computes point-by-point confidence intervals for the fitted function Parameters: n - number of points...
Definition: TFitter.cxx:115
Int_t fNlog
Definition: TFitter.h:33
Double_t y[n]
Definition: legend1.C:17
The TH1 histogram class.
Definition: TH1.h:80
virtual void SetFCN(void *fcn) R__DEPRECATED(6
To set the address of the minimization function.
Definition: TMinuit.cxx:958
virtual void mnexcm(const char *comand, Double_t *plist, Int_t llist, Int_t &ierflg)
Interprets a command and takes appropriate action.
Definition: TMinuit.cxx:2688
virtual void FixParameter(Int_t ipar)
Fix parameter ipar.
Definition: TFitter.cxx:98
TMinuit * fMinuit
Definition: TFitter.h:36
virtual void InitArgs(const Double_t *x, const Double_t *params)
Initialize parameters addresses.
Definition: TF1.cxx:2234
Abstract Base Class for Fitting.
TAxis * GetZaxis()
Definition: TH1.h:326
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Int_t GetNpar() const
Definition: TF1.h:349
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
Definition: TF1.cxx:1652
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2150
virtual void Clear(Option_t *option="")
reset the fitter environment
Definition: TFitter.cxx:71
double f2(const double *x)
1-Dim function class
Definition: TF1.h:149
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
Int_t GetN() const
Definition: TGraph2D.h:127
virtual Double_t * GetParameters() const
Definition: TF1.h:365
Double_t Sqrt(Double_t x)
Definition: TMath.h:464
void F3Fit(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag)
Definition: TFitter.cxx:613
virtual Int_t GetNumPars() const
returns the total number of parameters that have been defined as fixed or free.
Definition: TMinuit.cxx:881
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition: TGraph2D.h:50
virtual Int_t GetNumberTotalParameters() const
return the total number of parameters (free + fixed)
Definition: TFitter.cxx:410
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Double_t EvalPar(const Double_t *x, const Double_t *params=0)
Evaluate function with given coordinates and parameters.
Definition: TF1.cxx:1225
virtual TObject * GetUserFunc() const
virtual TObject * GetObjectFit() const
virtual Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const
return global fit parameters amin : chisquare edm : estimated distance to minimum errdef nvpar : numb...
Definition: TFitter.cxx:487
Int_t fNu
Definition: TMinuit.h:134
const Int_t n
Definition: legend1.C:16
gr SetName("gr")
char name[80]
Definition: TGX11.cxx:109
TAxis * GetXaxis()
Definition: TH1.h:324
Double_t * GetX() const
Definition: TGraph2D.h:128
const char * Data() const
Definition: TString.h:349
virtual Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh)
set initial values for a parameter ipar : parameter number parname : parameter name value : initial p...
Definition: TFitter.cxx:591