def bin_index(val, bins):
    """ Get bin index for a given value and a set of bin parameters """
    for index in range(0, len(bins) - 1):
        if bins[index] < val < bins[index + 1]:
            return index
    return len(bins) - 1