Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:52

0001 // @(#)root/tmva $Id$
0002 // Author: Asen Christov
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : KDEKernel                                                             *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      The Probability Density Functions (PDFs) used for the Likelihood analysis *
0012  *      can suffer from low statistics of the training samples. This can cause    *
0013  *      the PDFs to fluctuate instead to be smooth. Nonparamatric Kernel Density  *
0014  *      Estimation is one of the methods to produce "smooth" PDFs.                *
0015  *                                                                                *
0016  * Authors (alphabetical):                                                        *
0017  *      Asen Christov   <christov@physik.uni-freiburg.de> - Freiburg U., Germany  *
0018  *                                                                                *
0019  * Copyright (c) 2007:                                                            *
0020  *      CERN, Switzerland                                                         *
0021  *      MPI-K Heidelberg, Germany                                                 *
0022  *      Freiburg U., Germany                                                      *
0023  *                                                                                *
0024  * Redistribution and use in source and binary forms, with or without             *
0025  * modification, are permitted according to the terms listed in LICENSE           *
0026  * (see tmva/doc/LICENSE)                                          *
0027  **********************************************************************************/
0028 
0029 #ifndef ROOT_TMVA_KDEKernel
0030 #define ROOT_TMVA_KDEKernel
0031 
0032 //////////////////////////////////////////////////////////////////////////
0033 //                                                                      //
0034 // KDEKernel                                                            //
0035 //                                                                      //
0036 // KDE Kernel for "smoothing" the PDFs                                  //
0037 //                                                                      //
0038 //////////////////////////////////////////////////////////////////////////
0039 
0040 #include "Rtypes.h"
0041 
0042 class TH1;
0043 class TH1F;
0044 class TF1;
0045 
0046 namespace TMVA {
0047 
0048    class MsgLogger;
0049 
0050    class KDEKernel {
0051 
0052    public:
0053 
0054       enum EKernelType   { kNone = 0, kGauss = 1 };
0055       enum EKernelIter   { kNonadaptiveKDE = 1, kAdaptiveKDE = 2 };
0056       enum EKernelBorder { kNoTreatment = 1, kKernelRenorm = 2, kSampleMirror = 3 };
0057 
0058    public:
0059 
0060       KDEKernel( EKernelIter kiter = kNonadaptiveKDE, const TH1* hist = nullptr, Float_t lower_edge=0., Float_t upper_edge=1., EKernelBorder kborder = kNoTreatment, Float_t FineFactor = 1.);
0061 
0062       virtual ~KDEKernel( void );
0063 
0064       // calculates the integral of the Kernel function in the given bin.
0065       Float_t GetBinKernelIntegral(Float_t lowr, Float_t highr, Float_t mean, Int_t binnum);
0066 
0067       // sets the type of Kernel to be used (Default 1 mean Gaussian)
0068       void SetKernelType( EKernelType ktype = kGauss );
0069 
0070       // modified name (remove TMVA::)
0071       const char* GetName() const { return "KDEKernel"; }
0072 
0073    private:
0074 
0075       Float_t       fSigma;             ///< Width of the Kernel function
0076       EKernelIter   fIter;              ///< iteration number
0077       Float_t       fLowerEdge;         ///< the lower edge of the PDF
0078       Float_t       fUpperEdge;         ///< the upper edge of the PDF
0079       Float_t       fFineFactor;        ///< fine tuning factor for Adaptive KDE: factor to multiply the "width" of the Kernel function
0080       TF1          *fKernel_integ;      ///< the integral of the Kernel function
0081       EKernelBorder fKDEborder;         ///< The method to take care about "border" effects
0082       TH1F         *fHist;              ///< copy of input histogram
0083       TH1F         *fFirstIterHist;     ///< histogram to be filled in the hidden iteration
0084       TH1F         *fSigmaHist;         ///< contains the Sigmas Widths for adaptive KDE
0085       Bool_t        fHiddenIteration;   ///< Defines if whats currently running is the
0086       // (first) hidden iteration when doing adaptive KDE
0087 
0088       mutable MsgLogger* fLogger;       ///<! message logger
0089       MsgLogger& Log() const { return *fLogger; }
0090 
0091       ClassDef(KDEKernel,0); // Kernel density estimator for PDF smoothing
0092 
0093    };// namespace TMVA
0094 }
0095 #endif // KDEKernel_H