Пример #1
0
def test_jsd(p, q):
    from flotilla.compute.infotheory import jsd, kld

    result = jsd(p, q)

    weight = 0.5
    m = weight * (p + q)
    true_result = weight * kld(p, m) + (1 - weight) * kld(q, m)

    pdt.assert_series_equal(result, true_result)
Пример #2
0
def test_kld(p, q):
    from flotilla.compute.infotheory import kld
    result = kld(p, q)

    p = p.replace(0, np.nan)
    q = q.replace(0, np.nan)
    true_result = (np.log2(p / q) * p).sum(axis=0)

    pdt.assert_series_equal(result, true_result)
Пример #3
0
def test_kld(p, q):
    from flotilla.compute.infotheory import kld
    result = kld(p, q)

    p = p.replace(0, np.nan)
    q = q.replace(0, np.nan)
    true_result = (np.log2(p / q) * p).sum(axis=0)

    pdt.assert_series_equal(result, true_result)