Logo ROOT   6.10/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 #include "Math/IParamFunctionfwd.h"
17 #include "Fit/BinData.h"
18 #include "Fit/UnBinData.h"
19 
20 namespace ROOT {
21 
22  namespace Fit {
23 
24 
25 
26 
27 /**
28  namespace defining utility free functions using in Fit for evaluating the various fit method
29  functions (chi2, likelihood, etc..) given the data and the model function
30 
31  @ingroup FitMain
32 */
33 namespace FitUtil {
34 
37 
38  /** Chi2 Functions */
39 
40  /**
41  evaluate the Chi2 given a model function and the data at the point x.
42  return also nPoints as the effective number of used points in the Chi2 evaluation
43  */
44  double EvaluateChi2(const IModelFunction & func, const BinData & data, const double * x, unsigned int & nPoints);
45 
46  /**
47  evaluate the effective Chi2 given a model function and the data at the point x.
48  The effective chi2 uses the errors on the coordinates : W = 1/(sigma_y**2 + ( sigma_x_i * df/dx_i )**2 )
49  return also nPoints as the effective number of used points in the Chi2 evaluation
50  */
51  double EvaluateChi2Effective(const IModelFunction & func, const BinData & data, const double * x, unsigned int & nPoints);
52 
53  /**
54  evaluate the Chi2 gradient given a model function and the data at the point x.
55  return also nPoints as the effective number of used points in the Chi2 evaluation
56  */
57  void EvaluateChi2Gradient(const IModelFunction & func, const BinData & data, const double * x, double * grad, unsigned int & nPoints);
58 
59  /**
60  evaluate the LogL given a model function and the data at the point x.
61  return also nPoints as the effective number of used points in the LogL evaluation
62  */
63  double EvaluateLogL(const IModelFunction & func, const UnBinData & data, const double * x, int iWeight, bool extended, unsigned int & nPoints);
64 
65  /**
66  evaluate the LogL gradient given a model function and the data at the point x.
67  return also nPoints as the effective number of used points in the LogL evaluation
68  */
69  void EvaluateLogLGradient(const IModelFunction & func, const UnBinData & data, const double * x, double * grad, unsigned int & nPoints);
70 
71  /**
72  evaluate the Poisson LogL given a model function and the data at the point x.
73  return also nPoints as the effective number of used points in the LogL evaluation
74  By default is extended, pass extedend to false if want to be not extended (MultiNomial)
75  */
76  double EvaluatePoissonLogL(const IModelFunction & func, const BinData & data, const double * x, int iWeight, bool extended, unsigned int & nPoints);
77 
78  /**
79  evaluate the Poisson LogL given a model function and the data at the point x.
80  return also nPoints as the effective number of used points in the LogL evaluation
81  */
82  void EvaluatePoissonLogLGradient(const IModelFunction & func, const BinData & data, const double * x, double * grad);
83 
84 // /**
85 // Parallel evaluate the Chi2 given a model function and the data at the point x.
86 // return also nPoints as the effective number of used points in the Chi2 evaluation
87 // */
88 // double ParallelEvalChi2(const IModelFunction & func, const BinData & data, const double * x, unsigned int & nPoints);
89 
90  // methods required by dedicate minimizer like Fumili
91 
92  /**
93  evaluate the residual contribution to the Chi2 given a model function and the BinPoint data
94  and if the pointer g is not null evaluate also the gradient of the residual.
95  If the function provides parameter derivatives they are used otherwise a simple derivative calculation
96  is used
97  */
98  double EvaluateChi2Residual(const IModelFunction & func, const BinData & data, const double * x, unsigned int ipoint, double *g = 0);
99 
100  /**
101  evaluate the pdf contribution to the LogL given a model function and the BinPoint data.
102  If the pointer g is not null evaluate also the gradient of the pdf.
103  If the function provides parameter derivatives they are used otherwise a simple derivative calculation
104  is used
105  */
106  double EvaluatePdf(const IModelFunction & func, const UnBinData & data, const double * x, unsigned int ipoint, double * g = 0);
107 
108  /**
109  evaluate the pdf contribution to the Poisson LogL given a model function and the BinPoint data.
110  If the pointer g is not null evaluate also the gradient of the Poisson pdf.
111  If the function provides parameter derivatives they are used otherwise a simple derivative calculation
112  is used
113  */
114  double EvaluatePoissonBinPdf(const IModelFunction & func, const BinData & data, const double * x, unsigned int ipoint, double * g = 0);
115 
116 
117 
118 
119 
120 
121 
122 } // end namespace FitUtil
123 
124  } // end namespace Fit
125 
126 } // end namespace ROOT
127 
128 
129 #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:699
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
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:1105
Class describing the unbinned data sets (just x coordinates values) of any dimensions.
Definition: UnBinData.h:42
Interface (abstract class) for parametric gradient multi-dimensional functions providing in addition ...
ROOT::Math::IParamMultiGradFunction IGradModelFunction
Definition: FitUtil.h:36
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:1389
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:1063
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:473
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:892
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:594
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
Definition: BinData.h:53
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:1208
ROOT::Math::IParamMultiFunction IModelFunction
Definition: FitUtil.h:35
double EvaluateChi2(const IModelFunction &func, const BinData &data, const double *x, unsigned int &nPoints)
Chi2 Functions.
Definition: FitUtil.cxx:337
IParamFunction interface (abstract class) describing multi-dimensional parameteric functions It is a ...
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition: HFitImpl.cxx:134
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:844
double func(double *x, double *p)
Definition: stressTF1.cxx:213