public double entropy ( final String source ) { double output = 0 ; for ( int i = 1 ; i < source . length ( ) ; i ++ ) { TrieNode node = this . inner . matchEnd ( source . substring ( 0 , i ) ) ; Optional < ? extends TrieNode > child = node . getChild ( source . charAt ( i ) ) ; while ( ! child . isPresent ( ) ) { output += Math . log ( 1.0 / node . getCursorCount ( ) ) ; node = node . godparent ( ) ; child = node . getChild ( source . charAt ( i ) ) ; } output += Math . log ( child . get ( ) . getCursorCount ( ) * 1.0 / node . getCursorCount ( ) ) ; } return - output / Math . log ( 2 ) ; }
Entropy double .