Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMultiDimFit.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Christian Holm Christensen 07/11/2000
3
4#ifndef ROOT_TMultiDimFit
5#define ROOT_TMultiDimFit
6
7#include "TNamed.h"
8#include "TVectorD.h"
9#include "TMatrixD.h"
10#include "TVirtualFitter.h"
11
12class TBrowser;
13class TList;
14
15class TMultiDimFit : public TNamed {
16
17public:
22 };
23
24private:
25 static TMultiDimFit* fgInstance; // Static instance
26protected:
27
28 TVectorD fQuantity; ///< Training sample, dependent quantity
29 TVectorD fSqError; ///< Training sample, error in quantity
30 Double_t fMeanQuantity; ///< Mean of dependent quantity
31 Double_t fMaxQuantity; ///< Max value of dependent quantity
32 Double_t fMinQuantity; ///< Min value of dependent quantity
33 Double_t fSumSqQuantity; ///< SumSquare of dependent quantity
34 Double_t fSumSqAvgQuantity; ///< Sum of squares away from mean
35
36 TVectorD fVariables; ///< Training sample, independent variables
37 Int_t fNVariables; ///< Number of independent variables
38 TVectorD fMeanVariables; ///< mean value of independent variables
39 TVectorD fMaxVariables; ///< max value of independent variables
40 TVectorD fMinVariables; ///< min value of independent variables
41
42 Int_t fSampleSize; ///< Size of training sample
43
44 TVectorD fTestQuantity; ///< Test sample, dependent quantity
45 TVectorD fTestSqError; ///< Test sample, Error in quantity
46 TVectorD fTestVariables; ///< Test sample, independent variables
47
48 Int_t fTestSampleSize; ///< Size of test sample
49
50 Double_t fMinAngle; ///< Min angle for accepting new function
51 Double_t fMaxAngle; ///< Max angle for accepting new function
52 Int_t fMaxTerms; ///< Max terms expected in final expr.
53 Double_t fMinRelativeError; ///< Min relative error accepted
54 Int_t *fMaxPowers; ///<[fNVariables] maximum powers
55 Double_t fPowerLimit; ///< Control parameter
56
57
58 TMatrixD fFunctions; ///< Functions evaluated over sample
59 Int_t fMaxFunctions; ///< max number of functions
60 Int_t *fFunctionCodes; ///<[fMaxFunctions] acceptance code
61 Int_t fMaxStudy; ///< max functions to study
62 Int_t fMaxFuncNV; ///< fMaxFunctions*fNVariables
63
64 TMatrixD fOrthFunctions; ///< As above, but orthogonalised
65 TVectorD fOrthFunctionNorms; ///< Norm of the evaluated functions
66
67
68 Int_t *fMaxPowersFinal; ///<[fNVariables] maximum powers from fit;
69 Int_t *fPowers; ///<[fMaxFuncNV] where fMaxFuncNV = fMaxFunctions*fNVariables
70 Int_t *fPowerIndex; ///<[fMaxTerms] Index of accepted powers
71
72 TVectorD fResiduals; ///< Vector of the final residuals
73 Double_t fMaxResidual; ///< Max residual value
74 Double_t fMinResidual; ///< Min residual value
75 Int_t fMaxResidualRow; ///< Row giving max residual
76 Int_t fMinResidualRow; ///< Row giving min residual
77 Double_t fSumSqResidual; ///< Sum of Square residuals
78
79 Int_t fNCoefficients; ///< Dimension of model coefficients
80 TVectorD fOrthCoefficients; ///< The model coefficients
81 TMatrixD fOrthCurvatureMatrix; ///< Model matrix
82 TVectorD fCoefficients; ///< Vector of the final coefficients
83 TVectorD fCoefficientsRMS; ///< Vector of RMS of coefficients
84 Double_t fRMS; ///< Root mean square of fit
85 Double_t fChi2; ///< Chi square of fit
86 Int_t fParameterisationCode; ///< Exit code of parameterisation
87
88 Double_t fError; ///< Error from parametrization
89 Double_t fTestError; ///< Error from test
90 Double_t fPrecision; ///< Relative precision of param
91 Double_t fTestPrecision; ///< Relative precision of test
92 Double_t fCorrelationCoeff; ///< Multi Correlation coefficient
93 TMatrixD fCorrelationMatrix; ///< Correlation matrix
94 Double_t fTestCorrelationCoeff; ///< Multi Correlation coefficient
95
96 TList* fHistograms; ///< List of histograms
97 Byte_t fHistogramMask; ///< Bit pattern of histograms used
98 Int_t fBinVarX; ///< Number of bin in independent variables
99 Int_t fBinVarY; ///< Number of bin in dependent variables
100
101 TVirtualFitter* fFitter; //! Fit object (MINUIT)
102
103 EMDFPolyType fPolyType; ///< Type of polynomials to use
104 Bool_t fShowCorrelation; ///< print correlation matrix
105 Bool_t fIsUserFunction; ///< Flag for user defined function
107
108 virtual Double_t EvalFactor(Int_t p, Double_t x) const;
109 virtual Double_t EvalControl(const Int_t *powers) const;
110 virtual void MakeCoefficientErrors();
111 virtual void MakeCorrelation();
113 virtual void MakeCoefficients();
114 virtual void MakeCandidates();
115 virtual void MakeNormalized();
116 virtual void MakeParameterization();
117 virtual void MakeRealCode(const char *filename,
118 const char *classname,
119 Option_t *option="");
120 virtual Bool_t Select(const Int_t *iv);
121 virtual Bool_t TestFunction(Double_t squareResidual,
122 Double_t dResidur);
123public:
124 TMultiDimFit();
125 TMultiDimFit(Int_t dimension,
127 Option_t *option="");
128 ~TMultiDimFit() override;
129
130 virtual void AddRow(const Double_t *x, Double_t D, Double_t E=0);
131 virtual void AddTestRow(const Double_t *x, Double_t D, Double_t E=0);
132 void Browse(TBrowser* b) override;
133 void Clear(Option_t *option="") override; // *MENU*
134 void Draw(Option_t * ="d") override { }
135 virtual Double_t Eval(const Double_t *x, const Double_t *coeff = nullptr) const;
136 virtual Double_t EvalError(const Double_t *x, const Double_t *coeff = nullptr) const;
137 virtual void FindParameterization(Option_t* option=""); // *MENU*
138 virtual void Fit(Option_t *option=""); // *MENU*
139
140 Double_t GetChi2() const { return fChi2; }
142 const TVectorD* GetCoefficients() const { return &fCoefficients; }
143 const TVectorD* GetCoefficientsRMS() const { return &fCoefficientsRMS; }
144 Double_t GetError() const { return fError; }
146 const TMatrixD* GetFunctions() const { return &fFunctions; }
147 virtual TList* GetHistograms() const { return fHistograms; }
148 Double_t GetMaxAngle() const { return fMaxAngle; }
150 Int_t* GetMaxPowers() const { return fMaxPowers; }
152 Int_t GetMaxStudy() const { return fMaxStudy; }
153 Int_t GetMaxTerms() const { return fMaxTerms; }
154 const TVectorD* GetMaxVariables() const { return &fMaxVariables; }
156 const TVectorD* GetMeanVariables() const { return &fMeanVariables; }
157 Double_t GetMinAngle() const { return fMinAngle; }
160 const TVectorD* GetMinVariables() const { return &fMinVariables; }
161 Int_t GetNVariables() const { return fNVariables; }
163 Int_t GetPolyType() const { return fPolyType; }
164 Int_t* GetPowerIndex() const { return fPowerIndex; }
166 const Int_t* GetPowers() const { return fPowers; }
167 Double_t GetPrecision() const { return fPrecision; }
168 const TVectorD* GetQuantity() const { return &fQuantity; }
174 Double_t GetRMS() const { return fRMS; }
175 Int_t GetSampleSize() const { return fSampleSize; }
176 const TVectorD* GetSqError() const { return &fSqError; }
179 Double_t GetTestError() const { return fTestError; }
181 const TVectorD* GetTestQuantity() const { return &fTestQuantity; }
183 const TVectorD* GetTestSqError() const { return &fTestSqError; }
184 const TVectorD* GetTestVariables() const { return &fTestVariables; }
185 const TVectorD* GetVariables() const { return &fVariables; }
186
187 static TMultiDimFit* Instance();
188 Bool_t IsFolder() const override { return kTRUE; }
189 virtual Double_t MakeChi2(const Double_t* coeff = nullptr);
190 virtual void MakeCode(const char *functionName="MDF", Option_t *option=""); // *MENU*
191 virtual void MakeHistograms(Option_t* option="A"); // *MENU*
192 virtual void MakeMethod(const Char_t* className="MDF", Option_t* option=""); // *MENU*
193 void Print(Option_t *option="ps") const override; // *MENU*
194
195 void SetBinVarX(Int_t nbbinvarx) {fBinVarX = nbbinvarx;}
196 void SetBinVarY(Int_t nbbinvary) {fBinVarY = nbbinvary;}
197 void SetMaxAngle(Double_t angle=0);
199 void SetMaxPowers(const Int_t *powers);
201 void SetMaxTerms(Int_t terms) { fMaxTerms = terms; }
202 void SetMinRelativeError(Double_t error);
203 void SetMinAngle(Double_t angle=1);
204 void SetPowerLimit(Double_t limit=1e-3);
205 virtual void SetPowers(const Int_t *powers, Int_t terms);
206
207 ClassDefOverride(TMultiDimFit,2) // Multi dimensional fit class
208}
209;
210#endif
#define b(i)
Definition RSha256.hxx:100
#define e(i)
Definition RSha256.hxx:103
RooAbsReal & function()
int Int_t
Definition RtypesCore.h:45
unsigned char Byte_t
Definition RtypesCore.h:64
char Char_t
Definition RtypesCore.h:37
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint angle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
A doubly linked list.
Definition TList.h:38
Multidimensional Fits in ROOT.
const TVectorD * GetQuantity() const
Double_t GetSumSqAvgQuantity() const
void Print(Option_t *option="ps") const override
Print statistics etc.
virtual void MakeCorrelation()
PRIVATE METHOD: Compute the correlation matrix.
Int_t GetNCoefficients() const
Double_t GetMinQuantity() const
void SetMaxStudy(Int_t n)
TVectorD fCoefficients
Vector of the final coefficients.
Double_t fPrecision
Relative precision of param.
Double_t GetMaxAngle() const
Byte_t fHistogramMask
Bit pattern of histograms used.
void SetBinVarX(Int_t nbbinvarx)
virtual void MakeCoefficientErrors()
PRIVATE METHOD: Compute the errors on the coefficients.
void SetMaxFunctions(Int_t n)
Double_t GetTestPrecision() const
TMatrixD fOrthCurvatureMatrix
Model matrix.
Bool_t fShowCorrelation
print correlation matrix
Bool_t fIsUserFunction
Flag for user defined function.
Double_t GetError() const
Double_t GetRMS() const
Int_t fNVariables
Number of independent variables.
Int_t GetSampleSize() const
Int_t fMaxResidualRow
Row giving max residual.
Double_t fMinQuantity
Min value of dependent quantity.
virtual Double_t MakeChi2(const Double_t *coeff=nullptr)
Calculate Chi square over either the test sample.
Double_t fSumSqQuantity
SumSquare of dependent quantity.
TVectorD fMaxVariables
max value of independent variables
Double_t GetPrecision() const
const TVectorD * GetVariables() const
Int_t GetResidualMinRow() const
const TVectorD * GetMeanVariables() const
void SetMaxTerms(Int_t terms)
Double_t GetSumSqQuantity() const
Int_t fSampleSize
Size of training sample.
Double_t GetResidualSumSq() const
Double_t fSumSqAvgQuantity
Sum of squares away from mean.
Int_t fMaxTerms
Max terms expected in final expr.
Int_t * fPowers
[fMaxFuncNV] where fMaxFuncNV = fMaxFunctions*fNVariables
Double_t GetPowerLimit() const
virtual void MakeNormalized()
PRIVATE METHOD: Normalize data to the interval [-1;1].
Int_t * fMaxPowers
[fNVariables] maximum powers
Int_t GetNVariables() const
Int_t fMaxStudy
max functions to study
TVectorD fTestQuantity
Test sample, dependent quantity.
TVectorD fTestSqError
Test sample, Error in quantity.
void Draw(Option_t *="d") override
Default Draw method for all objects.
virtual Double_t Eval(const Double_t *x, const Double_t *coeff=nullptr) const
Evaluate parameterization at point x.
Int_t fMaxFunctions
max number of functions
Int_t fBinVarY
Number of bin in dependent variables.
static TMultiDimFit * Instance()
Return the static instance.
virtual void MakeCode(const char *functionName="MDF", Option_t *option="")
Generate the file <filename> with .C appended if argument doesn't end in .cxx or ....
virtual void MakeCandidates()
PRIVATE METHOD: Create list of candidate functions for the parameterisation.
const TVectorD * GetSqError() const
const TVectorD * GetMaxVariables() const
Double_t fTestError
Error from test.
Double_t fMinResidual
Min residual value.
void SetPowerLimit(Double_t limit=1e-3)
Set the user parameter for the function selection.
const TMatrixD * GetFunctions() const
virtual void FindParameterization(Option_t *option="")
Find the parameterization.
virtual Double_t MakeGramSchmidt(Int_t function)
PRIVATE METHOD: Make Gram-Schmidt orthogonalisation.
Int_t * GetMaxPowers() const
const TVectorD * GetMinVariables() const
TVectorD fSqError
Training sample, error in quantity.
virtual void AddRow(const Double_t *x, Double_t D, Double_t E=0)
Add a row consisting of fNVariables independent variables, the known, dependent quantity,...
Int_t GetTestSampleSize() const
Int_t GetResidualMaxRow() const
TVectorD fQuantity
Training sample, dependent quantity.
Double_t GetMinAngle() const
TVectorD fTestVariables
Test sample, independent variables.
TVectorD fOrthCoefficients
The model coefficients.
Int_t fTestSampleSize
Size of test sample.
TVectorD fResiduals
Vector of the final residuals.
const Int_t * GetPowers() const
virtual Bool_t TestFunction(Double_t squareResidual, Double_t dResidur)
PRIVATE METHOD: Test whether the currently considered function contributes to the fit.
TVectorD fVariables
Training sample, independent variables.
Double_t GetChi2() const
Double_t fCorrelationCoeff
Multi Correlation coefficient.
void SetMaxPowers(const Int_t *powers)
Set the maximum power to be considered in the fit for each variable.
Int_t * fMaxPowersFinal
[fNVariables] maximum powers from fit;
Int_t fMinResidualRow
Row giving min residual.
Int_t GetMaxTerms() const
virtual void SetPowers(const Int_t *powers, Int_t terms)
Define a user function.
Double_t fMaxQuantity
Max value of dependent quantity.
virtual void MakeRealCode(const char *filename, const char *classname, Option_t *option="")
PRIVATE METHOD: This is the method that actually generates the code for the evaluation the parameteri...
Double_t fRMS
Root mean square of fit.
TVirtualFitter * fFitter
TMatrixD fFunctions
Functions evaluated over sample.
Double_t GetResidualMin() const
virtual void AddTestRow(const Double_t *x, Double_t D, Double_t E=0)
Add a row consisting of fNVariables independent variables, the known, dependent quantity,...
Int_t fParameterisationCode
Exit code of parameterisation.
const TVectorD * GetTestVariables() const
Double_t fMaxAngle
Max angle for accepting new function.
Int_t fNCoefficients
Dimension of model coefficients.
virtual void Fit(Option_t *option="")
Try to fit the found parameterisation to the test sample.
TMultiDimFit()
Empty CTOR. Do not use.
virtual TList * GetHistograms() const
Double_t fTestCorrelationCoeff
Multi Correlation coefficient.
Int_t GetMaxStudy() const
Double_t GetMeanQuantity() const
Double_t fMinAngle
Min angle for accepting new function.
const TMatrixD * GetCorrelationMatrix() const
void SetMinRelativeError(Double_t error)
Set the acceptable relative error for when sum of square residuals is considered minimized.
Double_t fSumSqResidual
Sum of Square residuals.
Double_t GetResidualMax() const
TVectorD fMeanVariables
mean value of independent variables
void SetBinVarY(Int_t nbbinvary)
virtual void MakeMethod(const Char_t *className="MDF", Option_t *option="")
Generate the file <classname>MDF.cxx which contains the implementation of the method:
Double_t GetMinRelativeError() const
void SetMaxAngle(Double_t angle=0)
Set the max angle (in degrees) between the initial data vector to be fitted, and the new candidate fu...
Double_t fTestPrecision
Relative precision of test.
const TVectorD * GetTestSqError() const
virtual void MakeCoefficients()
PRIVATE METHOD: Invert the model matrix B, and compute final coefficients.
TMatrixD fCorrelationMatrix
Correlation matrix.
Int_t * GetPowerIndex() const
Int_t * fPowerIndex
[fMaxTerms] Index of accepted powers
TMatrixD fOrthFunctions
As above, but orthogonalised.
virtual Double_t EvalControl(const Int_t *powers) const
PRIVATE METHOD: Calculate the control parameter from the passed powers.
void Clear(Option_t *option="") override
Clear internal structures and variables.
virtual void MakeParameterization()
PRIVATE METHOD: Find the parameterization over the training sample.
EMDFPolyType fPolyType
Fit object (MINUIT)
void Browse(TBrowser *b) override
Browse the TMultiDimFit object in the TBrowser.
virtual Bool_t Select(const Int_t *iv)
Selection method.
Int_t GetMaxFunctions() const
TList * fHistograms
List of histograms.
Double_t GetTestError() const
Double_t fChi2
Chi square of fit.
Double_t fMaxResidual
Max residual value.
Double_t fError
Error from parametrization.
Int_t fBinVarX
Number of bin in independent variables.
Int_t * GetFunctionCodes() const
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
virtual Double_t EvalFactor(Int_t p, Double_t x) const
PRIVATE METHOD: Evaluate function with power p at variable value x.
const TVectorD * GetTestQuantity() const
void SetMinAngle(Double_t angle=1)
Set the min angle (in degrees) between a new candidate function and the subspace spanned by the previ...
virtual Double_t EvalError(const Double_t *x, const Double_t *coeff=nullptr) const
Evaluate parameterization error at point x.
TVectorD fMinVariables
min value of independent variables
TVectorD fOrthFunctionNorms
Norm of the evaluated functions.
const TVectorD * GetCoefficientsRMS() const
Double_t fMeanQuantity
Mean of dependent quantity.
const TVectorD * GetCoefficients() const
TVectorD fCoefficientsRMS
Vector of RMS of coefficients.
Double_t fPowerLimit
Control parameter.
static TMultiDimFit * fgInstance
Int_t GetPolyType() const
~TMultiDimFit() override
Destructor.
virtual void MakeHistograms(Option_t *option="A")
Make histograms of the result of the analysis.
Bool_t fIsVerbose
Int_t fMaxFuncNV
fMaxFunctions*fNVariables
Double_t GetMaxQuantity() const
Double_t fMinRelativeError
Min relative error accepted.
Int_t * fFunctionCodes
[fMaxFunctions] acceptance code
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Abstract Base Class for Fitting.
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16