def interpolate(offset,array):
  """Interpolate a 0-1 offset across an array of value"""
  if offset <= 0:
    return array[0]
  if offset >= 1:
    return array[-1]
  scale = len(array) - 1
  scaled_offset = offset * scale
  integer_part = int(scaled_offset)
  decimal_part = scaled_offset - integer_part
  return array[integer_part]*(1-decimal_part) + array[integer_part+1]*decimal_part