Defining weighted averages

Please make a minimal example; as described in: Read before posting: How do I get my question answered?