Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

double Impala::Core::Histogram::Entropy ( const Histogram::Histogram1dTem< int > *  hist  ) 

Definition at line 18 of file Entropy.h.

References Impala::Core::Vector::VectorTem< ElemT >::Elem(), Impala::Core::Vector::VectorTem< ElemT >::Size(), and Impala::Core::Histogram::Histogram1dTem< ElemT >::TotalWeight().

Referenced by Impala::Core::Feature::Gain(), Impala::Core::Histogram::TestEntropy::testKnownValues(), Impala::Core::Histogram::TestEntropy::testScaling(), and Impala::Core::Histogram::TestEntropy::testZeroPadding().

00019 {
00020     const double cLog2 = log(2.); // used for log with base 2
00021     double sum = hist->TotalWeight();
00022     if(sum == 0)
00023         return 0.;
00024     double e=0;
00025     for(int i=0 ; i<hist->Size() ; ++i)
00026     {
00027         double d = hist->Elem(i);
00028         if(d>0)
00029         {
00030             d /= sum;
00031             e -= d * (log(d)/cLog2);
00032         }
00033     }
00034     return e;
00035 }    

Here is the call graph for this function:


Generated on Fri Mar 19 11:12:06 2010 for ImpalaSrc by  doxygen 1.5.1