Added calculation of weighted averages and median values