def test_quantacc_basic(data=None): data = data or range(31) qa = ReservoirAccumulator() for v in data: qa.add(v) assert qa.median == _statsutils.median(data) q1, q2, q3 = qa.quartiles assert q1 < q2 < q3 return True
def test_acc_random(): data = test_sets['random.random 0.0-1.0'] qa = ReservoirAccumulator(data) capqa = ReservoirAccumulator(data, cap=True) p2qa = P2Accumulator(data) for acc in (qa, capqa, p2qa): for qp, v in acc.get_quantiles(): if qp > 0: assert 0.95 < (v / qp) < 1.05
def test_quantacc(): for name, data in test_sets.items(): qa = ReservoirAccumulator() for v in data: qa.add(v) _assert_round_cmp(qa.median, _statsutils.median(data), mag=6) q1, q2, q3 = qa.quartiles assert q1 < q2 < q3 hist = qa.get_histogram() assert hist
def test_p2quantacc(): for name, data in test_sets.items(): qa = ReservoirAccumulator() p2qa = P2Accumulator() for i, v in enumerate(data): p2qa.add(v) qa.add(v) if i and i % 1000 == 0: _assert_round_cmp(qa.median, p2qa.median, mag=1, name='%s median' % name) #print i, qa.median, p2qa.median _assert_round_cmp(qa.median, p2qa.median, mag=2, name='%s median' % name)