def lower_bound_index(desired_capacity, capacity_data):
    """Determines the index of the lower capacity value that defines a price segment.
    Useful for accessing the prices associated with capacity values that aren't
    explicitly stated in the capacity lists that are generated by the
    build_supply_curve() function. Needed for ks_test().

    :param float/int desired_capacity: Capacity value for which you want to determine
        the index of the lowest capacity value in a price segment.
    :param list capacity_data: List of capacity values used to generate a supply curve.
    :return: (*int*) -- Index of a price segment's capacity lower bound.
    """

    # Check that the list is not empty and that the capacity falls within the list range
    if not capacity_data or capacity_data[0] > desired_capacity:
        return None

    # Get the index of the capacity that is immediately less than the desired capacity
    for i, j in enumerate(capacity_data):
        if j > desired_capacity:
            return i - 1