Logo ROOT   6.12/07
Reference Guide
CrossEntropy.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : TMVA::CrossEntropy *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: Implementation of the CrossEntropy as separation criterion *
11  * -p log (p) - (1-p)log(1-p); p=purity *
12  * *
13  * *
14  * Authors (alphabetical): *
15  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
16  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
17  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
18  * *
19  * Copyright (c) 2005: *
20  * CERN, Switzerland *
21  * U. of Victoria, Canada *
22  * Heidelberg U., Germany *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://tmva.sourceforge.net/LICENSE) *
27  **********************************************************************************/
28 
29 /*! \class TMVA::CrossEntropy
30 \ingroup TMVA
31 
32 Implementation of the CrossEntropy as separation criterion
33 
34  -p log (p) - (1-p)log(1-p); p=purity
35 */
36 
37 #include "TMath.h"
38 #include "TMVA/CrossEntropy.h"
39 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Cross Entropy defined as:
44 ///
45 /// -p log (p) - (1-p)log(1-p); p=purity = s/(s+b)
46 
48 {
49  if (s+b <= 0) return 0;
50  Double_t p = s/(s+b);
51  if (p<=0 || p >=1) return 0;
52  // return - ( p * log (p) + (1-p)*log(1-p) );
53  return - ( p * TMath::Log2(p) + (1-p)*TMath::Log2(1-p) );
54 }
Double_t Log2(Double_t x)
Definition: TMath.cxx:104
Implementation of the CrossEntropy as separation criterion.
Definition: CrossEntropy.h:43
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
static constexpr double s
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual Double_t GetSeparationIndex(const Double_t s, const Double_t b)
Cross Entropy defined as: