def percentile(perc)
      if perc > 100.0 || perc < 0.0
        raise InvalidPercentile, "percentile must be between 0.0 and 100.0"
      end
      return 0.0 if data.empty?

      rank = (perc / 100.0) * (size + 1)

      return data[0]          if rank < 1
      return data[-1]         if rank > size
      return data[rank - 1]   if rank == Integer(rank)
      weighted_average_for(rank)
    end
def percentile(perc)
      if perc > 100.0 || perc < 0.0
        raise InvalidPercentile, "percentile must be between 0.0 and 100.0"
      end
      return 0.0 if data.empty?

      rank = (perc / 100.0) * (size + 1)

      return data[0]          if rank < 1
      return data[-1]         if rank > size
      return data[rank - 1]   if rank == Integer(rank)
      weighted_average_for(rank)
    end
Generate a percentile for the data set.
 @example
  snapshot.percentile(95)
  snapshot.percentile(99.9)