def remove_outliers(features, limit, min_size):
    """
    features = remove_outliers(features, limit, min_size)

    """
    nsize = int(limit * len(features))
    if nsize < min_size:
        return features
    normed = features - features.mean(0)
    std = normed.std(0)
    std[std == 0] = 1
    normed /= std
    f2_sum1 = (normed ** 2).mean(1)
    values = f2_sum1.copy()
    values.sort()
    top = values[nsize]
    selected = f2_sum1 < top
    return features[selected]
