예제 #1
0
def cov(xs, ys):
    """共分散"""
    n = len(xs)
    avg_x = mean.mean(xs)
    avg_y = mean.mean(ys)
    xs = map(lambda x: x - avg_x, xs)
    ys = map(lambda x: x - avg_y, ys)

    return sum(x * y for x, y in zip(xs, ys)) / n
예제 #2
0
def ssd(xs):
    """偏差平方和

    sum of squared deviation
    """
    avg = mean.mean(xs)
    return sum(map(lambda x: (x - avg) ** 2, xs))
예제 #3
0
def test_mean(xs, expected):
    assert mean.mean(xs) == expected
    assert mean.mean(xs) == stats.mean(xs)