code: def exam_reliability(x_axis, x_axis_new, reliable_distance, precision=0.0001):
      
      x_axis = x_axis[::-1]
      x_axis.append(-2**32)
  
      distance_to_closest_point = list()
      for t in x_axis_new:
          while 1:
              try:
                  x = x_axis.pop()
                  if x <= t:
                      left = x
                  else:
                      right = x
                      x_axis.append(right)
                      x_axis.append(left)
                      left_dist, right_dist = (t - left), (right - t)
                      if left_dist <= right_dist:
                          distance_to_closest_point.append(left_dist)
                      else:
                          distance_to_closest_point.append(right_dist)
                      break
              except:
                  distance_to_closest_point.append(t - left)
                  break
  
      reliable_flag = list()
      for dist in distance_to_closest_point:
          if dist - precision - reliable_distance <= 0:
              reliable_flag.append(True)
          else:
              reliable_flag.append(False)
  
      return reliable_flag
docs: When we do linear interpolation on x_axis and derive value for 
      x_axis_new, we also evaluate how can we trust those interpolated 
      data points. This is how it works:
  
      For each new x_axis point in x_axis new, let's say xi. Find the closest 
      point in x_axis, suppose the distance is #dist. Compare this to 
      #reliable_distance. If #dist < #reliable_distance, then we can trust it, 
      otherwise, we can't.
  
      The precision is to handle decimal value's precision problem. Because 
      1.0 may actually is 1.00000000001 or 0.999999999999 in computer system. 
      So we define that: if ``dist`` + ``precision`` <= ``reliable_distance``, then we 
      can trust it, else, we can't.
  
      Here is an O(n) algorithm implementation. A lots of improvement than 
      classic binary search one, which is O(n^2).