Beispiel #1
0
def check(t, alpha, eps, delta, beta, samples_size=0, use_exponential=True):
    """
    run flat_concave on random data using the given parameters
    :param t:
    :param alpha:
    :param eps:
    :param delta:
    :param beta:
    :param samples_size:
    :param use_exponential:
    :return:
    """
    range_end = 2**t
    if samples_size == 0:
        samples_size = int(
            src.bounds.step6_n2_bound(range_end, eps, alpha, beta))
    data_center = np.random.uniform(range_end / 3, range_end / 3 * 2)
    # data = src.examples.get_random_data(samples_size, distribution_type='splitted', pivot=data_center)
    # data = src.examples.get_random_data(samples_size, 'bimodal')
    data = src.examples.get_random_data(samples_size, pivot=data_center)
    data = sorted(filter(lambda x: 0 <= x <= range_end, data))
    maximum_quality = min_max_maximum_quality(data, 0, range_end)
    quality_result_lower_bound = maximum_quality * (1 - alpha)
    try:
        result = src.flat_concave.evaluate(data, range_end, quality_minmax,
                                           maximum_quality, alpha, eps, delta,
                                           min_max_intervals_bounding,
                                           min_max_maximum_quality,
                                           use_exponential)
        result_quality = quality_minmax(data, result)
    except ValueError:
        # result = -1
        result_quality = -1
    return result_quality != -1, result_quality >= quality_result_lower_bound, result_quality / float(
        maximum_quality)
Beispiel #2
0
def check(t, alpha, eps, delta, beta, samples_size=0, use_exponential=True):
    """
    run flat_concave on random data using the given parameters
    :param t:
    :param alpha:
    :param eps:
    :param delta:
    :param beta:
    :param samples_size:
    :param use_exponential:
    :return:
    """
    range_end = 2**t
    if samples_size == 0:
        samples_size = int(src.bounds.step6_n2_bound(range_end, eps, alpha, beta))
    data_center = np.random.uniform(range_end/3, range_end/3*2)
    # data = src.examples.get_random_data(samples_size, distribution_type='splitted', pivot=data_center)
    # data = src.examples.get_random_data(samples_size, 'bimodal')
    data = src.examples.get_random_data(samples_size, pivot=data_center)
    data = sorted(filter(lambda x: 0 <= x <= range_end, data))
    maximum_quality = min_max_maximum_quality(data, 0, range_end)
    quality_result_lower_bound = maximum_quality * (1-alpha)
    try:
        result = src.flat_concave.evaluate(data, range_end, quality_minmax, maximum_quality, alpha, eps, delta,
                                       min_max_intervals_bounding, min_max_maximum_quality,
                                       use_exponential)
        result_quality = quality_minmax(data, result)
    except ValueError:
        # result = -1
        result_quality = -1
    return result_quality != -1, result_quality >= quality_result_lower_bound, result_quality/float(maximum_quality)
Beispiel #3
0
def compare_maximum_in_interval_versions():
    range_end = 2**40

    samples_size = uniform(1000,2000)
    print "range size: %d" % range_end
    print "sample size: %d" % samples_size
    data_center = np.random.uniform(range_end/3, range_end/3*2)
    data = xp.get_random_data(samples_size, pivot=data_center)
    data = sorted(filter(lambda x: 0 <= x <= range_end, data))

    maximum_quality1 = ql.min_max_maximum_quality(data, 0, range_end)
    maximum_quality2 = ql.__old_min_max_maximum_quality__(data, (0, range_end))
    print maximum_quality1 == maximum_quality2
Beispiel #4
0
def compare_maximum_in_interval_versions():
    range_end = 2**40

    samples_size = uniform(1000, 2000)
    print "range size: %d" % range_end
    print "sample size: %d" % samples_size
    data_center = np.random.uniform(range_end / 3, range_end / 3 * 2)
    data = xp.get_random_data(samples_size, pivot=data_center)
    data = sorted(filter(lambda x: 0 <= x <= range_end, data))

    maximum_quality1 = ql.min_max_maximum_quality(data, 0, range_end)
    maximum_quality2 = ql.__old_min_max_maximum_quality__(data, (0, range_end))
    print maximum_quality1 == maximum_quality2