Newer
Older
adaptive-nback / tests / common.py


# Common benchmark parameters
choices = alphabetic_choices = ['A', 'B', 'C', 'D', 'E', 'F']
trials_range = (10, 65)
n = 4
sample_size = 100


def count_targets_and_lures(seq, n):
    mask = 'D'*n
    for index in range(n, len(seq)):
        if seq[index] == seq[index - n]:
            mask += 'T'
        elif seq[index] in seq[index - n - 1:index - n + 1]:
            mask += 'L'
        else:
            mask += 'D'
    return mask.count('T'), mask.count('L')


def skewness(seq, choices):
    import heapq
    trials = len(seq)
    freqs = [float(seq.count(c)) for c in choices]
    ralph_skewed = sum(heapq.nlargest(int(len(choices) / 2), freqs)) > (trials * 2 / 3)
    return ralph_skewed