question: public double entropy ( int [ ] x ) { double h = 0.0 ; int n = x . length ; double ln2 = Math . log ( 2.0 ) ; int n0 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( x [ i ] == 0 ) { n0 ++ ; } } double p ; if ( n0 == 0 || n0 == n ) { return h ; } else { p = ( double ) n0 / ( double ) n ; h = - ( p * Math . log ( p ) + ( 1.0 - p ) * Math . log ( 1.0 - p ) ) / ln2 ; } return h ; }
target:  This method computes the entropy of a binary signal stored in an int array.  It assume that the values in the array are 0's and 1's. (Actually 1's may be replaced by any nonzero value)  See page 20 of the Liang paper.