// @(#)root/tmva $Id$ 
// Author: Asen Christov

/**********************************************************************************
 * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
 * Package: TMVA                                                                  *
 * Class  : KDEKernel                                                             *
 * Web    : http://tmva.sourceforge.net                                           *
 *                                                                                *
 * Description:                                                                   *
 *      The Probability Density Functions (PDFs) used for the Likelihood analysis *
 *      can suffer from low statistics of the training samples. This can couse    *
 *      the PDFs to fluctuate instead to be smooth. Nonparamatric Kernel Density  *
 *      Estimation is one of the methods to produse "smooth" PDFs.                *
 *                                                                                *
 * Authors (alphabetical):                                                        *
 *      Asen Christov   <christov@physik.uni-freiburg.de> - Freiburg U., Germany  *
 *                                                                                *
 * Copyright (c) 2007:                                                            *
 *      CERN, Switzerland                                                         * 
 *      MPI-K Heidelberg, Germany                                                 * 
 *      Freiburg U., Germany                                                      * 
 *                                                                                *
 * Redistribution and use in source and binary forms, with or without             *
 * modification, are permitted according to the terms listed in LICENSE           *
 * (http://tmva.sourceforge.net/LICENSE)                                          *
 **********************************************************************************/

#ifndef ROOT_TMVA_KDEKernel
#define ROOT_TMVA_KDEKernel

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// KDEKernel                                                            //
//                                                                      //
// KDE Kernel for "smoothing" the PDFs                                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif

class TH1;
class TH1F;
class TF1;

namespace TMVA {

   class MsgLogger;

   class KDEKernel {

   public:

      enum EKernelType   { kNone = 0, kGauss = 1 };
      enum EKernelIter   { kNonadaptiveKDE = 1, kAdaptiveKDE = 2 };
      enum EKernelBorder { kNoTreatment = 1, kKernelRenorm = 2, kSampleMirror = 3 };
    
   public:
       
      KDEKernel( EKernelIter kiter = kNonadaptiveKDE, const TH1* hist = 0, Float_t lower_edge=0., Float_t upper_edge=1., EKernelBorder kborder = kNoTreatment, Float_t FineFactor = 1.);
      
      virtual ~KDEKernel( void );
    
      // calculates the integral of the Kernel function in the given bin.
      Float_t GetBinKernelIntegral(Float_t lowr, Float_t highr, Float_t mean, Int_t binnum);
      
      // sets the type of Kernel to be used (Default 1 mean Gaussian)
      void SetKernelType( EKernelType ktype = kGauss );
      
      // modified name (remove TMVA::)
      const char* GetName() const { return "KDEKernel"; }

   private:
      
      Float_t       fSigma;             // Width of the Kernel function
      EKernelIter   fIter;              // iteration number
      Float_t       fLowerEdge;         // the lower edge of the PDF
      Float_t       fUpperEdge;         // the upper edge of the PDF
      Float_t       fFineFactor;        // fine tuning factor for Adaptive KDE: factor to multiply the "width" of the Kernel function
      TF1          *fKernel_integ;      // the integral of the Kernel function
      EKernelBorder fKDEborder;         // The method to take care about "border" effects
      TH1F         *fHist;              // copy of input histogram
      TH1F         *fFirstIterHist;      // histogram to be filled in the hidden iteration
      TH1F         *fSigmaHist;         // contains the Sigmas Widths for adaptive KDE 
      Bool_t        fHiddenIteration;   // Defines if whats currently running is the 
                                     // (first) hidden iteration when doing adaptive KDE

      mutable MsgLogger* fLogger;   // message logger
      MsgLogger& Log() const { return *fLogger; }    
      
      ClassDef(KDEKernel,0) // Kernel density estimator for PDF smoothing
      
   };// namespace TMVA
}
#endif // KDEKernel_H
 KDEKernel.h:1
 KDEKernel.h:2
 KDEKernel.h:3
 KDEKernel.h:4
 KDEKernel.h:5
 KDEKernel.h:6
 KDEKernel.h:7
 KDEKernel.h:8
 KDEKernel.h:9
 KDEKernel.h:10
 KDEKernel.h:11
 KDEKernel.h:12
 KDEKernel.h:13
 KDEKernel.h:14
 KDEKernel.h:15
 KDEKernel.h:16
 KDEKernel.h:17
 KDEKernel.h:18
 KDEKernel.h:19
 KDEKernel.h:20
 KDEKernel.h:21
 KDEKernel.h:22
 KDEKernel.h:23
 KDEKernel.h:24
 KDEKernel.h:25
 KDEKernel.h:26
 KDEKernel.h:27
 KDEKernel.h:28
 KDEKernel.h:29
 KDEKernel.h:30
 KDEKernel.h:31
 KDEKernel.h:32
 KDEKernel.h:33
 KDEKernel.h:34
 KDEKernel.h:35
 KDEKernel.h:36
 KDEKernel.h:37
 KDEKernel.h:38
 KDEKernel.h:39
 KDEKernel.h:40
 KDEKernel.h:41
 KDEKernel.h:42
 KDEKernel.h:43
 KDEKernel.h:44
 KDEKernel.h:45
 KDEKernel.h:46
 KDEKernel.h:47
 KDEKernel.h:48
 KDEKernel.h:49
 KDEKernel.h:50
 KDEKernel.h:51
 KDEKernel.h:52
 KDEKernel.h:53
 KDEKernel.h:54
 KDEKernel.h:55
 KDEKernel.h:56
 KDEKernel.h:57
 KDEKernel.h:58
 KDEKernel.h:59
 KDEKernel.h:60
 KDEKernel.h:61
 KDEKernel.h:62
 KDEKernel.h:63
 KDEKernel.h:64
 KDEKernel.h:65
 KDEKernel.h:66
 KDEKernel.h:67
 KDEKernel.h:68
 KDEKernel.h:69
 KDEKernel.h:70
 KDEKernel.h:71
 KDEKernel.h:72
 KDEKernel.h:73
 KDEKernel.h:74
 KDEKernel.h:75
 KDEKernel.h:76
 KDEKernel.h:77
 KDEKernel.h:78
 KDEKernel.h:79
 KDEKernel.h:80
 KDEKernel.h:81
 KDEKernel.h:82
 KDEKernel.h:83
 KDEKernel.h:84
 KDEKernel.h:85
 KDEKernel.h:86
 KDEKernel.h:87
 KDEKernel.h:88
 KDEKernel.h:89
 KDEKernel.h:90
 KDEKernel.h:91
 KDEKernel.h:92
 KDEKernel.h:93
 KDEKernel.h:94
 KDEKernel.h:95
 KDEKernel.h:96
 KDEKernel.h:97