Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TKDE.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Authors: Bartolomeu Rabacal 07/2010
3/**********************************************************************
4 * *
5 * Copyright (c) 2006 , LCG ROOT MathLib Team *
6 * *
7 * *
8 **********************************************************************/
9// Header file for TKDE
10
11#ifndef ROOT_TKDE
12#define ROOT_TKDE
13
15
16#include "TNamed.h"
17
18#include "Math/Math.h"
19
20#include <string>
21#include <vector>
22#include <memory>
23
24class TGraphErrors;
25class TF1;
26
27/*
28 Kernel Density Estimation class.
29 The three main references are
30
31 (1) "Scott DW, Multivariate Density Estimation.Theory, Practice and Visualization. New York: Wiley",
32 (2) "Jann Ben - ETH Zurich, Switzerland -, Univariate kernel density estimation document for KDENS: Stata module for univariate kernel density estimation."
33 (3) "Hardle W, Muller M, Sperlich S, Werwatz A, Nonparametric and Semiparametric Models. Springer."The algorithm is briefly described in
34 "Cranmer KS, Kernel Estimation in High-Energy Physics. Computer Physics Communications 136:198-207,2001" - e-Print Archive: hep ex/0011057.
35 A binned version is also implemented to address the performance issue due to its data size dependence.
36*/
37class TKDE : public TNamed {
38public:
39
40 /// Types of Kernel functions
41 /// They can be set using the function SetKernelType() or as a string in the constructor
47 kUserDefined, ///< Internal use only for the class's template constructor
48 kTotalKernels ///< Internal use only for member initialization
49 };
50
51 /// Iteration types. They can be set using SetIteration()
54 kFixed
55 };
56
57 /// Data "mirroring" option to address the probability "spill out" boundary effect
58 /// They can be set using SetMirror()
59 enum EMirror {
69 };
70
71 /// Data binning option.
72 /// They can be set using SetBinning()
75 kRelaxedBinning, ///< The algorithm is allowed to use binning if the data is large enough
77 };
78
79 /// default constructor used only by I/O
80 TKDE();
81
82 /// Constructor for unweighted data
83 /// Varius option for TKDE can be passed in the option string as below.
84 /// Note that min and max will define the plotting range but will not restrict the data in the unbinned case
85 /// Instead when use binning, only the data in the range will be considered.
86 /// Note also, that when some data exists outside the range, one should not use the mirror option with unbinned.
87 /// Adaptive will be soon very slow especially for Nevents > 10000.
88 /// For this reason, by default for Nevents >=10000, the data are automatically binned in
89 /// nbins=Min(10000,Nevents/10)
90 /// In case of ForceBinning option the default number of bins is 1000
91 TKDE(UInt_t events, const Double_t* data, Double_t xMin = 0.0, Double_t xMax = 0.0, const Option_t* option =
92 "KernelType:Gaussian;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho = 1.0) {
93 Instantiate( nullptr, events, data, nullptr, xMin, xMax, option, rho);
94 }
95
96 /// Constructor for weighted data
97 TKDE(UInt_t events, const Double_t* data, const Double_t* dataWeight, Double_t xMin = 0.0, Double_t xMax = 0.0, const Option_t* option =
98 "KernelType:Gaussian;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho = 1.0) {
99 Instantiate( nullptr, events, data, dataWeight, xMin, xMax, option, rho);
100 }
101
102 /// Constructor for unweighted data and a user defined kernel function
103 template<class KernelFunction>
104 TKDE(const Char_t* /*name*/, const KernelFunction& kernfunc, UInt_t events, const Double_t* data, Double_t xMin = 0.0, Double_t xMax = 0.0, const Option_t* option = "KernelType:UserDefined;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho = 1.0) {
105 Instantiate(new ROOT::Math::WrappedFunction<const KernelFunction&>(kernfunc), events, data, nullptr, xMin, xMax, option, rho);
106 }
107
108 /// Constructor for weighted data and a user defined kernel function
109 template<class KernelFunction>
110 TKDE(const Char_t* /*name*/, const KernelFunction& kernfunc, UInt_t events, const Double_t* data, const Double_t * dataWeight, Double_t xMin = 0.0, Double_t xMax = 0.0, const Option_t* option = "KernelType:UserDefined;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho = 1.0) {
111 Instantiate(new ROOT::Math::WrappedFunction<const KernelFunction&>(kernfunc), events, data, dataWeight, xMin, xMax, option, rho);
112 }
113
114 ~TKDE() override;
115
116 void Fill(Double_t data);
117 void Fill(Double_t data, Double_t weight);
118 void SetKernelType(EKernelType kern);
119 void SetIteration(EIteration iter);
120 void SetMirror(EMirror mir);
121 void SetBinning(EBinning);
122 void SetNBins(UInt_t nbins);
123 void SetUseBinsNEvents(UInt_t nEvents);
124 void SetTuneFactor(Double_t rho);
125 void SetRange(Double_t xMin, Double_t xMax); ///< By default computed from the data
126
127 void Draw(const Option_t* option = "") override;
128
130 Double_t operator()(const Double_t* x, const Double_t* p = nullptr) const; // Needed for creating TF1
131
132 Double_t GetValue(Double_t x) const { return (*this)(x); }
134
135 Double_t GetBias(Double_t x) const;
136 Double_t GetMean() const;
137 Double_t GetSigma() const;
138 Double_t GetRAMISE() const;
139
140 Double_t GetFixedWeight() const;
141
142 TF1* GetFunction(UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
143 TF1* GetUpperFunction(Double_t confidenceLevel = 0.95, UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
144 TF1* GetLowerFunction(Double_t confidenceLevel = 0.95, UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
145 TF1* GetApproximateBias(UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
146 TGraphErrors * GetGraphWithErrors(UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
147
148 /// @name Drawn objects getters
149 /// Allow to change settings
150 /// These objects are managed by TKDE and should not be deleted by the user
151 ///@{
152 TF1 * GetDrawnFunction() { return fPDF;}
156 ///@}
157
158 const Double_t * GetAdaptiveWeights() const;
159
160
161public:
162
163 class TKernel {
165 UInt_t fNWeights; ///< Number of kernel weights (bandwidth as vectorized for binning)
166 std::vector<Double_t> fWeights; ///< Kernel weights (bandwidth)
167 public:
168 TKernel(Double_t weight, TKDE *kde);
172 Double_t GetFixedWeight() const;
173 const std::vector<Double_t> &GetAdaptiveWeights() const;
174 };
175
176 friend class TKernel;
177
178private:
179
180 TKDE(TKDE& kde); // Disallowed copy constructor
181 TKDE operator=(TKDE& kde); // Disallowed assign operator
182
183 // Kernel function pointer. It is managed by class for internal kernels or externally for user defined kernels
185 KernelFunction_Ptr fKernelFunction; ///<! pointer to kernel function
186
187 std::unique_ptr<TKernel> fKernel; ///<! internal kernel class. Transient because it is recreated after reading from a file
188
189 std::vector<Double_t> fData; ///< Data events
190 std::vector<Double_t> fEvents; ///< Original data storage
191 std::vector<Double_t> fEventWeights; ///< Original data weights
192
193 TF1* fPDF; //! Output Kernel Density Estimation PDF function
194 TF1* fUpperPDF; //! Output Kernel Density Estimation upper confidence interval PDF function
195 TF1* fLowerPDF; //! Output Kernel Density Estimation lower confidence interval PDF function
196 TF1* fApproximateBias; //! Output Kernel Density Estimation approximate bias
197 TGraphErrors* fGraph; //! Graph with the errors
198
203
204
207 Bool_t fNewData; ///< Flag to control when new data are given
208 Bool_t fUseMinMaxFromData; ///< Flag top control if min and max must be used from data
209
210 UInt_t fNBins; ///< Number of bins for binned data option
211 UInt_t fNEvents; ///< Data's number of events
212 Double_t fSumOfCounts; ///< Data sum of weights
213 UInt_t fUseBinsNEvents; ///< If the algorithm is allowed to use automatic (relaxed) binning this is the minimum number of events to do so
214
215 Double_t fMean; ///< Data mean
216 Double_t fSigma; ///< Data std deviation
217 Double_t fSigmaRob; ///< Data std deviation (robust estimation)
218 Double_t fXMin; ///< Data minimum value
219 Double_t fXMax; ///< Data maximum value
220 Double_t fRho; ///< Adjustment factor for sigma
221 Double_t fAdaptiveBandwidthFactor; ///< Geometric mean of the kernel density estimation from the data for adaptive iteration
222
223 Double_t fWeightSize; ///< Caches the weight size
224
225 std::vector<Double_t> fCanonicalBandwidths;
226 std::vector<Double_t> fKernelSigmas2;
227
228 std::vector<Double_t> fBinCount; ///< Number of events per bin for binned data option
229
230 std::vector<Bool_t> fSettedOptions; ///< User input options flag
231
232 struct KernelIntegrand;
233 friend struct KernelIntegrand;
234
235 void Instantiate(KernelFunction_Ptr kernfunc, UInt_t events, const Double_t* data, const Double_t* weight,
236 Double_t xMin, Double_t xMax, const Option_t* option, Double_t rho);
237
238 /// Returns the kernel evaluation at x
240 Double_t k2_PI_ROOT_INV = 0.398942280401432703; // (2 * M_PI)**-0.5
241 return (x > -9. && x < 9.) ? k2_PI_ROOT_INV * std::exp(-.5 * x * x) : 0.0;
242 }
243
245 return (x > -1. && x < 1.) ? 3. / 4. * (1. - x * x) : 0.0;
246 }
247
248 /// Returns the kernel evaluation at x
250 return (x > -1. && x < 1.) ? 15. / 16. * (1. - x * x) * (1. - x * x) : 0.0;
251 }
252
253 /// Returns the kernel evaluation at x
255 return (x > -1. && x < 1.) ? M_PI_4 * std::cos(M_PI_2 * x) : 0.0;
256 }
257 Double_t UpperConfidenceInterval(const Double_t* x, const Double_t* p) const; ///< Valid if the bandwidth is small compared to nEvents**1/5
258 Double_t LowerConfidenceInterval(const Double_t* x, const Double_t* p) const; ///< Valid if the bandwidth is small compared to nEvents**1/5
259 Double_t ApproximateBias(const Double_t* x, const Double_t* ) const { return GetBias(*x); }
265 void ComputeDataStats() ;
266
267 UInt_t Index(Double_t x) const;
268
270 void SetBinCountData();
271 void CheckKernelValidity();
273 void SetUserKernelSigma2();
275 void SetKernelSigmas2();
277 void SetUseBins();
278 void SetMirror();
279 void SetMean();
280 void SetSigma(Double_t R);
281 void SetKernel();
282 void SetKernelFunction(KernelFunction_Ptr kernfunc = nullptr);
283 void SetOptions(const Option_t* option, Double_t rho);
284 void CheckOptions(Bool_t isUserDefinedKernel = kFALSE);
285 void GetOptions(std::string optionType, std::string option);
286 void AssureOptions();
287 void SetData(const Double_t* data, const Double_t * weights);
288 void ReInit();
289 void InitFromNewData();
290 void SetMirroredEvents();
291 void SetDrawOptions(const Option_t* option, TString& plotOpt, TString& drawOpt);
292 void DrawErrors(TString& drawOpt);
293 void DrawConfidenceInterval(TString& drawOpt, double cl=0.95);
294
295 TF1* GetKDEFunction(UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
296 TF1* GetKDEApproximateBias(UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
297 // The density to estimate should be at least twice differentiable.
298 TF1* GetPDFUpperConfidenceInterval(Double_t confidenceLevel = 0.95, UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
299 TF1* GetPDFLowerConfidenceInterval(Double_t confidenceLevel = 0.95, UInt_t npx = 100, Double_t xMin = 1.0, Double_t xMax = 0.0);
300
301 ClassDefOverride(TKDE, 3) // One dimensional semi-parametric Kernel Density Estimation
302
303};
304
305#endif
#define M_PI_2
Definition Math.h:40
#define M_PI_4
Definition Math.h:44
char Char_t
Definition RtypesCore.h:37
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
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 data
float xmin
float xmax
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition IFunction.h:112
Template class to wrap any C++ callable object which takes one argument i.e.
1-Dim function class
Definition TF1.h:214
A TGraphErrors is a TGraph with error bars.
std::vector< Double_t > fWeights
Kernel weights (bandwidth)
Definition TKDE.h:166
void ComputeAdaptiveWeights()
Definition TKDE.cxx:776
Double_t GetFixedWeight() const
Definition TKDE.cxx:1000
Double_t GetWeight(Double_t x) const
Definition TKDE.cxx:814
Double_t operator()(Double_t x) const
Definition TKDE.cxx:1010
UInt_t fNWeights
Number of kernel weights (bandwidth as vectorized for binning)
Definition TKDE.h:165
TKDE * fKDE
Definition TKDE.h:164
const std::vector< Double_t > & GetAdaptiveWeights() const
Definition TKDE.cxx:1005
Kernel Density Estimation class.
Definition TKDE.h:37
~TKDE() override
Definition TKDE.cxx:77
TF1 * GetPDFUpperConfidenceInterval(Double_t confidenceLevel=0.95, UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:1245
TF1 * GetKDEApproximateBias(UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:1271
void SetData(const Double_t *data, const Double_t *weights)
Definition TKDE.cxx:442
TF1 * fLowerPDF
Output Kernel Density Estimation upper confidence interval PDF function.
Definition TKDE.h:195
std::vector< Double_t > fKernelSigmas2
Definition TKDE.h:226
Double_t ComputeKernelL2Norm() const
Definition TKDE.cxx:1124
TF1 * fPDF
Definition TKDE.h:193
TF1 * GetPDFLowerConfidenceInterval(Double_t confidenceLevel=0.95, UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:1258
void SetKernelType(EKernelType kern)
Definition TKDE.cxx:309
std::vector< Double_t > fCanonicalBandwidths
Definition TKDE.h:225
UInt_t fNEvents
Data's number of events.
Definition TKDE.h:211
void ComputeDataStats()
Internal function to compute statistics (mean,stddev) using always all the provided data (i....
Definition TKDE.cxx:1162
Double_t fXMax
Data maximum value.
Definition TKDE.h:219
Double_t UpperConfidenceInterval(const Double_t *x, const Double_t *p) const
Valid if the bandwidth is small compared to nEvents**1/5.
Definition TKDE.cxx:1063
void ReInit()
Definition TKDE.cxx:478
TF1 * GetDrawnUpperFunction()
Definition TKDE.h:153
Double_t ApproximateBias(const Double_t *x, const Double_t *) const
Definition TKDE.h:259
Double_t ComputeMidspread()
Definition TKDE.cxx:1191
Bool_t fNewData
Flag to control when new data are given.
Definition TKDE.h:207
void SetMirror()
Definition TKDE.cxx:433
Bool_t fUseMirroring
Definition TKDE.h:205
void DrawConfidenceInterval(TString &drawOpt, double cl=0.95)
// Draws the KDE and its confidence interval
Definition TKDE.cxx:965
TF1 * GetDrawnLowerFunction()
Definition TKDE.h:154
void SetMirroredEvents()
Intgernal function to mirror the data.
Definition TKDE.cxx:526
EMirror fMirror
Definition TKDE.h:201
void SetUserCanonicalBandwidth()
Definition TKDE.cxx:1202
Bool_t fMirrorLeft
Definition TKDE.h:205
EIteration fIteration
Definition TKDE.h:200
void CheckKernelValidity()
Definition TKDE.cxx:1100
TKDE(const Char_t *, const KernelFunction &kernfunc, UInt_t events, const Double_t *data, const Double_t *dataWeight, Double_t xMin=0.0, Double_t xMax=0.0, const Option_t *option="KernelType:UserDefined;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho=1.0)
Constructor for weighted data and a user defined kernel function.
Definition TKDE.h:110
const Double_t * GetAdaptiveWeights() const
Definition TKDE.cxx:990
Double_t fAdaptiveBandwidthFactor
Geometric mean of the kernel density estimation from the data for adaptive iteration.
Definition TKDE.h:221
TF1 * GetDrawnFunction()
Definition TKDE.h:152
void SetKernelFunction(KernelFunction_Ptr kernfunc=nullptr)
Definition TKDE.cxx:625
Double_t LowerConfidenceInterval(const Double_t *x, const Double_t *p) const
Valid if the bandwidth is small compared to nEvents**1/5.
Definition TKDE.cxx:1072
Double_t fSigmaRob
Data std deviation (robust estimation)
Definition TKDE.h:217
std::vector< Double_t > fBinCount
Number of events per bin for binned data option.
Definition TKDE.h:228
EBinning fBinning
Definition TKDE.h:202
EIteration
Iteration types. They can be set using SetIteration()
Definition TKDE.h:52
@ kAdaptive
Definition TKDE.h:53
@ kFixed
Definition TKDE.h:54
Double_t GetRAMISE() const
Definition TKDE.cxx:763
void SetIteration(EIteration iter)
Definition TKDE.cxx:321
Double_t ComputeKernelIntegral() const
Definition TKDE.cxx:1151
Double_t CosineArchKernel(Double_t x) const
Returns the kernel evaluation at x.
Definition TKDE.h:254
Double_t fXMin
Data minimum value.
Definition TKDE.h:218
Double_t operator()(Double_t x) const
Definition TKDE.cxx:741
void SetUserKernelSigma2()
Definition TKDE.cxx:1207
Double_t GetBias(Double_t x) const
Definition TKDE.cxx:1082
std::vector< Double_t > fData
Data events.
Definition TKDE.h:189
Double_t fSumOfCounts
Data sum of weights.
Definition TKDE.h:212
UInt_t fUseBinsNEvents
If the algorithm is allowed to use automatic (relaxed) binning this is the minimum number of events t...
Definition TKDE.h:213
void SetKernel()
Definition TKDE.cxx:596
Double_t fSigma
Data std deviation.
Definition TKDE.h:216
TGraphErrors * GetGraphWithErrors(UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
return a TGraphErrors with the KDE values and errors The return object is managed by the user
Definition TKDE.cxx:940
Double_t GetMean() const
Definition TKDE.cxx:751
Double_t fRho
Adjustment factor for sigma.
Definition TKDE.h:220
ROOT::Math::IBaseFunctionOneDim * KernelFunction_Ptr
Definition TKDE.h:184
Bool_t fAsymRight
Definition TKDE.h:205
Double_t fWeightSize
Caches the weight size.
Definition TKDE.h:223
void SetUseBinsNEvents(UInt_t nEvents)
Definition TKDE.cxx:364
std::vector< Double_t > fEvents
Original data storage.
Definition TKDE.h:190
Double_t GetError(Double_t x) const
Definition TKDE.cxx:1091
TF1 * GetKDEFunction(UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:1231
void SetBinning(EBinning)
Definition TKDE.cxx:339
void GetOptions(std::string optionType, std::string option)
Definition TKDE.cxx:198
Double_t GetValue(Double_t x) const
Definition TKDE.h:132
Bool_t fAsymLeft
Definition TKDE.h:205
std::vector< Bool_t > fSettedOptions
User input options flag.
Definition TKDE.h:230
Double_t GaussianKernel(Double_t x) const
Returns the kernel evaluation at x.
Definition TKDE.h:239
void SetRange(Double_t xMin, Double_t xMax)
By default computed from the data.
Definition TKDE.cxx:380
void SetMean()
Definition TKDE.cxx:585
Double_t ComputeKernelSigma2() const
Definition TKDE.cxx:1133
void SetOptions(const Option_t *option, Double_t rho)
Definition TKDE.cxx:126
void SetUseBins()
Definition TKDE.cxx:394
Double_t GetFixedWeight() const
Definition TKDE.cxx:979
void AssureOptions()
Definition TKDE.cxx:270
TF1 * GetFunction(UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:689
void SetBinCountData()
Definition TKDE.cxx:828
TF1 * GetUpperFunction(Double_t confidenceLevel=0.95, UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:698
void InitFromNewData()
Definition TKDE.cxx:500
void Instantiate(KernelFunction_Ptr kernfunc, UInt_t events, const Double_t *data, const Double_t *weight, Double_t xMin, Double_t xMax, const Option_t *option, Double_t rho)
Definition TKDE.cxx:91
void SetDrawOptions(const Option_t *option, TString &plotOpt, TString &drawOpt)
Definition TKDE.cxx:152
EMirror
Data "mirroring" option to address the probability "spill out" boundary effect They can be set using ...
Definition TKDE.h:59
@ kMirrorRightAsymLeft
Definition TKDE.h:65
@ kMirrorLeft
Definition TKDE.h:61
@ kMirrorAsymRight
Definition TKDE.h:66
@ kMirrorAsymBoth
Definition TKDE.h:68
@ kNoMirror
Definition TKDE.h:60
@ kMirrorRight
Definition TKDE.h:62
@ kMirrorLeftAsymRight
Definition TKDE.h:67
@ kMirrorBoth
Definition TKDE.h:63
@ kMirrorAsymLeft
Definition TKDE.h:64
TGraphErrors * GetDrawnGraph()
Definition TKDE.h:155
TKDE(TKDE &kde)
TGraphErrors * fGraph
Output Kernel Density Estimation approximate bias.
Definition TKDE.h:197
void SetCanonicalBandwidths()
Definition TKDE.cxx:672
TKDE()
default constructor used only by I/O
Definition TKDE.cxx:61
void SetBinCentreData(Double_t xmin, Double_t xmax)
Definition TKDE.cxx:819
TKDE(const Char_t *, const KernelFunction &kernfunc, UInt_t events, const Double_t *data, Double_t xMin=0.0, Double_t xMax=0.0, const Option_t *option="KernelType:UserDefined;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho=1.0)
Constructor for unweighted data and a user defined kernel function.
Definition TKDE.h:104
void SetTuneFactor(Double_t rho)
Definition TKDE.cxx:370
void Fill(Double_t data)
Definition TKDE.cxx:713
TF1 * fUpperPDF
Output Kernel Density Estimation PDF function.
Definition TKDE.h:194
Bool_t fMirrorRight
Definition TKDE.h:205
UInt_t fNBins
Number of bins for binned data option.
Definition TKDE.h:210
Double_t ComputeKernelMu() const
Definition TKDE.cxx:1142
EKernelType
Types of Kernel functions They can be set using the function SetKernelType() or as a string in the co...
Definition TKDE.h:42
@ kGaussian
Definition TKDE.h:43
@ kEpanechnikov
Definition TKDE.h:44
@ kCosineArch
Definition TKDE.h:46
@ kBiweight
Definition TKDE.h:45
@ kTotalKernels
Internal use only for member initialization.
Definition TKDE.h:48
@ kUserDefined
Internal use only for the class's template constructor.
Definition TKDE.h:47
Double_t fMean
Data mean.
Definition TKDE.h:215
void DrawErrors(TString &drawOpt)
Draws a TGraphErrors with KDE values and errors.
Definition TKDE.cxx:931
void SetNBins(UInt_t nbins)
Definition TKDE.cxx:346
void CheckOptions(Bool_t isUserDefinedKernel=kFALSE)
Definition TKDE.cxx:286
Double_t EpanechnikovKernel(Double_t x) const
Definition TKDE.h:244
Double_t BiweightKernel(Double_t x) const
Returns the kernel evaluation at x.
Definition TKDE.h:249
void SetKernelSigmas2()
Definition TKDE.cxx:681
std::unique_ptr< TKernel > fKernel
! internal kernel class. Transient because it is recreated after reading from a file
Definition TKDE.h:187
Bool_t fUseMinMaxFromData
Flag top control if min and max must be used from data.
Definition TKDE.h:208
Double_t GetSigma() const
Definition TKDE.cxx:757
EKernelType fKernelType
Graph with the errors.
Definition TKDE.h:199
TF1 * fApproximateBias
Output Kernel Density Estimation lower confidence interval PDF function.
Definition TKDE.h:196
TKDE operator=(TKDE &kde)
void SetSigma(Double_t R)
Definition TKDE.cxx:590
TKDE(UInt_t events, const Double_t *data, Double_t xMin=0.0, Double_t xMax=0.0, const Option_t *option="KernelType:Gaussian;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho=1.0)
Constructor for unweighted data Varius option for TKDE can be passed in the option string as below.
Definition TKDE.h:91
std::vector< Double_t > fEventWeights
Original data weights.
Definition TKDE.h:191
TF1 * GetApproximateBias(UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:708
TF1 * GetLowerFunction(Double_t confidenceLevel=0.95, UInt_t npx=100, Double_t xMin=1.0, Double_t xMax=0.0)
Definition TKDE.cxx:703
Bool_t fUseBins
Definition TKDE.h:206
TKDE(UInt_t events, const Double_t *data, const Double_t *dataWeight, Double_t xMin=0.0, Double_t xMax=0.0, const Option_t *option="KernelType:Gaussian;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", Double_t rho=1.0)
Constructor for weighted data.
Definition TKDE.h:97
KernelFunction_Ptr fKernelFunction
! pointer to kernel function
Definition TKDE.h:185
EBinning
Data binning option.
Definition TKDE.h:73
@ kUnbinned
Definition TKDE.h:74
@ kRelaxedBinning
The algorithm is allowed to use binning if the data is large enough.
Definition TKDE.h:75
@ kForcedBinning
Definition TKDE.h:76
void SetHistogram()
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Basic string class.
Definition TString.h:139
Double_t x[n]
Definition legend1.C:17
th1 Draw()