patched percentile function to address bugs with very high and low percentiles for smaller arrays (i.e. p99)