def generalized_iqr(x, left_cutoff=0.25, right_cutoff=0.25):
    """Returns the width of the distribution given by x, cutting
    off the left and right tails at the specified cutoff values.
    """
    if len(x) == 0:
        return float('NaN')

    sorted_vals = sorted(x)
    left_index = int(len(x)*left_cutoff)
    right_index = int(len(x)*(1 - right_cutoff))
    iqr = sorted_vals[right_index] - sorted_vals[left_index]
    return iqr