Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
32Implementation 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}
#define b(i)
Definition RSha256.hxx:100
#define ClassImp(name)
Definition Rtypes.h:377
winID h TVirtualViewer3D TVirtualGLPainter p
Implementation of the CrossEntropy as separation criterion.
virtual Double_t GetSeparationIndex(const Double_t s, const Double_t b)
Cross Entropy defined as:
Double_t Log2(Double_t x)
Returns the binary (base-2) logarithm of x.
Definition TMath.cxx:107