Use the medianAndAvgByPeriod function in GrimoireUtils.