Implement quantile estimate algorithm (definition 8)