Added weighted_sum method.