Logo ROOT   6.08/07
Reference Guide
GiniIndex.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::GiniIndex *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: Implementation of the GiniIndex as separation criterion *
11  * Large Gini Indices (maximum 0.5) mean , that the sample is well *
12  * mixed (same amount of signal and bkg) *
13  * bkg. Small Indices mean, well separated. *
14  * general defniniton: *
15  * Gini(Sample M) = 1 - (c(1)/N)^2 - (c(2)/N)^2 .... - (c(k)/N)^2 *
16  * Where: M is a smaple of whatever N elements (events) *
17  * that belong to K different classes *
18  * c(k) is the number of elements that belong to class k *
19  * for just Signal and Background classes this boils down to: *
20  * Gini(Sample) = 2s*b/(s+b)^2 *
21  * *
22  * Authors (alphabetical): *
23  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
24  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
25  * Kai Voss <Kai.Voss@cern.ch> - U. of Victoria, Canada *
26  * *
27  * Copyright (c) 2005: *
28  * CERN, Switzerland *
29  * U. of Victoria, Canada *
30  * Heidelberg U., Germany *
31  * *
32  * Redistribution and use in source and binary forms, with or without *
33  * modification, are permitted according to the terms listed in LICENSE *
34  * (http://tmva.sourceforge.net/LICENSE) *
35  **********************************************************************************/
36 
37 //_______________________________________________________________________
38 //
39 // Implementation of the GiniIndex as separation criterion
40 //
41 //_______________________________________________________________________
42 
43 #include "TMVA/GiniIndex.h"
44 
45 #include "Rtypes.h"
46 
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// Gini(Sample M) = 1 - (c(1)/N)^2 - (c(2)/N)^2 .... - (c(k)/N)^2
51 /// Where: M is a smaple of whatever N elements (events)
52 /// that belong to K different classes
53 /// c(k) is the number of elements that belong to class k
54 /// for just Signal and Background classes this boils down to:
55 /// Gini(Sample) = 2s*b/(s+b)^2 ( = 2 * purity * (1-purity) )
56 ///
57 /// !! what we use here is 2*Gini.. as for the later use the factor
58 /// 2 is irrelevant and hence I'd like to save this calculation
59 
60 Double_t TMVA::GiniIndex::GetSeparationIndex( const Double_t &s, const Double_t &b )
61 {
62  if (s+b <= 0) return 0;
63  if (s<=0 || b <=0) return 0;
64  // else return s*b/(s+b)/(s+b);
65  else return 2*s*b/(s+b)/(s+b);
66 }
67 
68 
#define ClassImp(name)
Definition: Rtypes.h:279
double Double_t
Definition: RtypesCore.h:55
Abstract ClassifierFactory template that handles arbitrary types.
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