

def approxrand(a, b, **kwargs):
    '\n    Returns an approximate significance level between two lists of\n    independently generated test values.\n\n    Approximate randomization calculates significance by randomly drawing\n    from a sample of the possible permutations. At the limit of the number\n    of possible permutations, the significance level is exact. The\n    approximate significance level is the sample mean number of times the\n    statistic of the permutated lists varies from the actual statistic of\n    the unpermuted argument lists.\n\n    :return: a tuple containing an approximate significance level, the count\n             of the number of times the pseudo-statistic varied from the\n             actual statistic, and the number of shuffles\n    :rtype: tuple\n    :param a: a list of test values\n    :type a: list\n    :param b: another list of independently generated test values\n    :type b: list\n    '
    shuffles = kwargs.get('shuffles', 999)
    shuffles = min(shuffles, reduce(operator.mul, xrange(1, ((len(a) + len(b)) + 1))))
    stat = kwargs.get('statistic', (lambda lst: (sum(lst) / len(lst))))
    verbose = kwargs.get('verbose', False)
    if verbose:
        print(('shuffles: %d' % shuffles))
    actual_stat = fabs((stat(a) - stat(b)))
    if verbose:
        print(('actual statistic: %f' % actual_stat))
        print(('-' * 60))
    c = 1e-100
    lst = LazyConcatenation([a, b])
    indices = list(range((len(a) + len(b))))
    for i in xrange(shuffles):
        if (verbose and ((i % 10) == 0)):
            print(('shuffle: %d' % i))
        shuffle(indices)
        pseudo_stat_a = stat(LazyMap((lambda i: lst[i]), indices[:len(a)]))
        pseudo_stat_b = stat(LazyMap((lambda i: lst[i]), indices[len(a):]))
        pseudo_stat = fabs((pseudo_stat_a - pseudo_stat_b))
        if (pseudo_stat >= actual_stat):
            c += 1
        if (verbose and ((i % 10) == 0)):
            print(('pseudo-statistic: %f' % pseudo_stat))
            print(('significance: %f' % ((c + 1) / (i + 1))))
            print(('-' * 60))
    significance = ((c + 1) / (shuffles + 1))
    if verbose:
        print(('significance: %f' % significance))
        if betai:
            for phi in [0.01, 0.05, 0.1, 0.15, 0.25, 0.5]:
                print(('prob(phi<=%f): %f' % (phi, betai(c, shuffles, phi))))
    return (significance, c, shuffles)

dataset/ETHPy150Open nltk/nltk/nltk/metrics/scores.py approxrand/original