def meanXperY(x, y):
    """find the mean x for each label y"""
    sums = dict()
    counts = dict()
    for i in range(len(x)):
        try:
            sums[y[i]] += x[i]
            counts[y[i]] += 1
        except KeyError:
            sums[y[i]] = x
            counts[y[i]] = 1
    means = dict()
    for yKey in sums:
        means[yKey] = sums[yKey] / float(counts[yKey])
    return means
