ROOT  6.06/09
Reference Guide
FitUtil.h
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id$
2 // Author: L. Moneta Tue Nov 28 10:52:47 2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class FitUtil
12 
13 #ifndef ROOT_Fit_FitUtil
14 #define ROOT_Fit_FitUtil
15 
16 #ifndef ROOT_Math_IParamFunctionfwd
17 #include "Math/IParamFunctionfwd.h"
18 #endif
19 
20 #ifndef ROOT_Fit_DataVectorfwd
21 #include "Fit/DataVectorfwd.h"
22 #endif
23 
24 
25 namespace ROOT {
26 
27  namespace Fit {
28 
29 
30 
31 
32 /**
33  namespace defining utility free functions using in Fit for evaluating the various fit method
34  functions (chi2, likelihood, etc..) given the data and the model function
35 
36  @ingroup FitMain
37 */
38 namespace FitUtil {
39 
42 
43  /** Chi2 Functions */
44 
45  /**
46  evaluate the Chi2 given a model function and the data at the point x.
47  return also nPoints as the effective number of used points in the Chi2 evaluation
48  */
49  double EvaluateChi2(const IModelFunction & func, const BinData & data, const double * x, unsigned int & nPoints);
50 
51  /**
52  evaluate the effective Chi2 given a model function and the data at the point x.
53  The effective chi2 uses the errors on the coordinates : W = 1/(sigma_y**2 + ( sigma_x_i * df/dx_i )**2 )
54  return also nPoints as the effective number of used points in the Chi2 evaluation
55  */
56  double EvaluateChi2Effective(const IModelFunction & func, const BinData & data, const double * x, unsigned int & nPoints);
57 
58  /**
59  evaluate the Chi2 gradient given a model function and the data at the point x.
60  return also nPoints as the effective number of used points in the Chi2 evaluation
61  */
62  void EvaluateChi2Gradient(const IModelFunction & func, const BinData & data, const double * x, double * grad, unsigned int & nPoints);
63 
64  /**
65  evaluate the LogL given a model function and the data at the point x.
66  return also nPoints as the effective number of used points in the LogL evaluation
67  */
68  double EvaluateLogL(const IModelFunction & func, const UnBinData & data, const double * x, int iWeight, bool extended, unsigned int & nPoints);
69 
70  /**
71  evaluate the LogL gradient given a model function and the data at the point x.
72  return also nPoints as the effective number of used points in the LogL evaluation
73  */
74  void EvaluateLogLGradient(const IModelFunction & func, const UnBinData & data, const double * x, double * grad, unsigned int & nPoints);
75 
76  /**
77  evaluate the Poisson LogL given a model function and the data at the point x.
78  return also nPoints as the effective number of used points in the LogL evaluation
79  By default is extended, pass extedend to false if want to be not extended (MultiNomial)
80  */
81  double EvaluatePoissonLogL(const IModelFunction & func, const BinData & data, const double * x, int iWeight, bool extended, unsigned int & nPoints);
82 
83  /**
84  evaluate the Poisson LogL given a model function and the data at the point x.
85  return also nPoints as the effective number of used points in the LogL evaluation
86  */
87  void EvaluatePoissonLogLGradient(const IModelFunction & func, const BinData & data, const double * x, double * grad);
88 
89 // /**
90 // Parallel evaluate the Chi2 given a model function and the data at the point x.
91 // return also nPoints as the effective number of used points in the Chi2 evaluation
92 // */
93 // double ParallelEvalChi2(const IModelFunction & func, const BinData & data, const double * x, unsigned int & nPoints);
94 
95  // methods required by dedicate minimizer like Fumili
96 
97  /**
98  evaluate the residual contribution to the Chi2 given a model function and the BinPoint data
99  and if the pointer g is not null evaluate also the gradient of the residual.
100  If the function provides parameter derivatives they are used otherwise a simple derivative calculation
101  is used
102  */
103  double EvaluateChi2Residual(const IModelFunction & func, const BinData & data, const double * x, unsigned int ipoint, double *g = 0);
104 
105  /**
106  evaluate the pdf contribution to the LogL given a model function and the BinPoint data.
107  If the pointer g is not null evaluate also the gradient of the pdf.
108  If the function provides parameter derivatives they are used otherwise a simple derivative calculation
109  is used
110  */
111  double EvaluatePdf(const IModelFunction & func, const UnBinData & data, const double * x, unsigned int ipoint, double * g = 0);
112 
113  /**
114  evaluate the pdf contribution to the Poisson LogL given a model function and the BinPoint data.
115  If the pointer g is not null evaluate also the gradient of the Poisson pdf.
116  If the function provides parameter derivatives they are used otherwise a simple derivative calculation
117  is used
118  */
119  double EvaluatePoissonBinPdf(const IModelFunction & func, const BinData & data, const double * x, unsigned int ipoint, double * g = 0);
120 
121 
122 
123 
124 
125 
126 
127 } // end namespace FitUtil
128 
129  } // end namespace Fit
130 
131 } // end namespace ROOT
132 
133 
134 #endif /* ROOT_Fit_FitUtil */
void EvaluateChi2Gradient(const IModelFunction &func, const BinData &data, const double *x, double *grad, unsigned int &nPoints)
evaluate the Chi2 gradient given a model function and the data at the point x.
Definition: FitUtil.cxx:698
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
double EvaluatePoissonBinPdf(const IModelFunction &func, const BinData &data, const double *x, unsigned int ipoint, double *g=0)
evaluate the pdf contribution to the Poisson LogL given a model function and the BinPoint data...
Definition: FitUtil.cxx:1058
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
Definition: UnBinData.h:47
ROOT::Math::IParamMultiGradFunction IGradModelFunction
Definition: FitUtil.h:41
void EvaluatePoissonLogLGradient(const IModelFunction &func, const BinData &data, const double *x, double *grad)
evaluate the Poisson LogL given a model function and the data at the point x.
Definition: FitUtil.cxx:1342
Double_t x[n]
Definition: legend1.C:17
void EvaluateLogLGradient(const IModelFunction &func, const UnBinData &data, const double *x, double *grad, unsigned int &nPoints)
evaluate the LogL gradient given a model function and the data at the point x.
Definition: FitUtil.cxx:1016
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
double EvaluateChi2Effective(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints)
evaluate the effective Chi2 given a model function and the data at the point x.
Definition: FitUtil.cxx:472
double EvaluateLogL(const IModelFunction &func, const UnBinData &data, const double *x, int iWeight, bool extended, unsigned int &nPoints)
evaluate the LogL given a model function and the data at the point x.
Definition: FitUtil.cxx:891
double EvaluateChi2Residual(const IModelFunction &func, const BinData &data, const double *x, unsigned int ipoint, double *g=0)
Parallel evaluate the Chi2 given a model function and the data at the point x.
Definition: FitUtil.cxx:593
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
Definition: BinData.h:61
double EvaluatePoissonLogL(const IModelFunction &func, const BinData &data, const double *x, int iWeight, bool extended, unsigned int &nPoints)
evaluate the Poisson LogL given a model function and the data at the point x.
Definition: FitUtil.cxx:1161
ROOT::Math::IParamMultiFunction IModelFunction
Definition: FitUtil.h:40
double EvaluateChi2(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints)
Chi2 Functions.
Definition: FitUtil.cxx:336
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:132
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
double EvaluatePdf(const IModelFunction &func, const UnBinData &data, const double *x, unsigned int ipoint, double *g=0)
evaluate the pdf contribution to the LogL given a model function and the BinPoint data...
Definition: FitUtil.cxx:843
double func(double *x, double *p)
Definition: stressTF1.cxx:213