Computes a weighted mean over an array of values.