CrossEntropy.cxx

Go to the documentation of this file.
00001 // @(#)root/tmva $Id: CrossEntropy.cxx 29122 2009-06-22 06:51:30Z brun $       
00002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss, Kai Voss 
00003 
00004 /**********************************************************************************
00005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
00006  * Package: TMVA                                                                  *
00007  * Class  : TMVA::CrossEntropy                                                    *
00008  * Web    : http://tmva.sourceforge.net                                           *
00009  *                                                                                *
00010  * Description: Implementation of the CrossEntropy as separation criterion        *
00011  *              -p log (p) - (1-p)log(1-p);     p=purity                          * 
00012  *                                                                                *
00013  *                                                                                *
00014  * Authors (alphabetical):                                                        *
00015  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
00016  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
00017  *      Kai Voss        <Kai.Voss@cern.ch>       - U. of Victoria, Canada         *
00018  *                                                                                *
00019  * Copyright (c) 2005:                                                            *
00020  *      CERN, Switzerland                                                         * 
00021  *      U. of Victoria, Canada                                                    * 
00022  *      Heidelberg U., Germany                                                    * 
00023  *                                                                                *
00024  * Redistribution and use in source and binary forms, with or without             *
00025  * modification, are permitted according to the terms listed in LICENSE           *
00026  * (http://tmva.sourceforge.net/LICENSE)                                          *
00027  **********************************************************************************/
00028 
00029 //_______________________________________________________________________
00030 //                                                                      
00031 // Implementation of the CrossEntropy as separation criterion           
00032 //             -p log (p) - (1-p)log(1-p);     p=purity                        
00033 //_______________________________________________________________________
00034 
00035 #include <math.h>
00036 #include "TMVA/CrossEntropy.h"
00037 
00038 ClassImp(TMVA::CrossEntropy)
00039    
00040 //_______________________________________________________________________
00041 Double_t  TMVA::CrossEntropy::GetSeparationIndex( const Double_t &s, const Double_t &b )
00042 {
00043    //  Cross Entropy defined as
00044    //  -p log (p) - (1-p)log(1-p);     p=purity = s/(s+b)                       
00045    if (s+b <= 0) return 0;
00046    Double_t p = s/(s+b);
00047    if (p<=0 || p >=1) return 0;
00048    return - ( p * log (p) + (1-p)*log(1-p) );
00049 }

Generated on Tue Jul 5 15:16:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1