public static < E > Distribution < E > getDistributionFromLogValues ( Counter < E > counter ) { ClassicCounter < E > c = new ClassicCounter < E > ( ) ; // go through once to get the max // shift all by max so as to minimize the possibility of underflow double max = Counters . max ( counter ) ; // Thang 17Feb12: max should operate on counter instead of c, fixed! for ( E key : counter . keySet ( ) ) { double count = Math . exp ( counter . getCount ( key ) - max ) ; c . setCount ( key , count ) ; } return getDistribution ( c ) ; }
Creates a Distribution from the given counter ie makes an internal copy of the counter and divides all counts by the total count .