import math


def _GetPercentile(sortedlist, percent):
  """Returns a desired percentile value of a sorted list of numbers.

  E.g., if a list of request latencies is
  [1, 4, 7, 14, 34, 89, 100, 123, 149, 345], and percent is 0.9, the result
  is 149. If percent is 0.5 (median), result is 34.

  Args:
    sortedlist: A sorted list of integers, longs or floats.
    percent: A fraction between 0 and 1 that indicates desired
      percentile value. E.g., 0.9 means 90th percentile is desired.
  Returns:
    None if list is empty. Else, the desired percentile value.
  """
  if not sortedlist:
    return None




  k = int(math.ceil(len(sortedlist) * percent)) - 1
  if k < 0:


    k = 0
  return sortedlist[k]