public static < E > Counter < E > linearCombination ( Counter < E > c1 , double w1 , Counter < E > c2 , double w2 ) { Counter < E > result = c1 . getFactory ( ) . create ( ) ; for ( E o : c1 . keySet ( ) ) { result . incrementCount ( o , c1 . getCount ( o ) * w1 ) ; } for ( E o : c2 . keySet ( ) ) { result . incrementCount ( o , c2 . getCount ( o ) * w2 ) ; } return result ; }
Returns a Counter which is a weighted average of c1 and c2 . Counts from c1 are weighted with weight w1 and counts from c2 are weighted with w2 .