weighted_mean_sd function

Helper function to compute weighted mean and standard deviation