예제 #1
0
def test_sum_first_half_of_first_bin():
    # test sum at point between min and first bin value
    # https://github.com/carsonfarmer/streamhist/issues/13
    h = StreamHist(maxbins=5)
    h.update((1, 2, 3, 4, 5, .5))
    assert h.min() == 0.5
    bin0 = h.bins[0]
    assert bin0.value == 0.75
    assert bin0.count == 2
    assert h.sum(h.min()) == 0
    assert h.sum((h.min() + bin0.value) / 2) == (.5**2) * bin0.count / 2
예제 #2
0
def test_freeze():
    points = 100000
    h = StreamHist(freeze=500)
    for p in make_normal(points):
        h.update(p)
    assert about(h.sum(0), points / 2.0, points / 50.0)
    assert about(h.median(), 0, 0.05)
    assert about(h.mean(), 0, 0.05)
    assert about(h.var(), 1, 0.05)
예제 #3
0
def test_freeze():
    points = 100000
    h = StreamHist(freeze=500)
    for p in make_normal(points):
        h.update(p)
    assert about(h.sum(0), points/2.0, points/50.0)
    assert about(h.median(), 0, 0.05)
    assert about(h.mean(), 0, 0.05)
    assert about(h.var(), 1, 0.05)
예제 #4
0
def test_cdf_pdf():
    points = 10000
    h = StreamHist()
    data = make_normal(points)
    h.update(data)
    assert about(h.sum(0), points / 2.0, points / 50.0)
예제 #5
0
def test_sum_edges():
    h = StreamHist().update(0).update(10)
    assert h.sum(5) == 1
    assert h.sum(0) == 0.5
    assert h.sum(10) == 2
예제 #6
0
def test_cdf_pdf():
    points = 10000
    h = StreamHist()
    data = make_normal(points)
    h.update(data)
    assert about(h.sum(0), points/2.0, points/50.0)
예제 #7
0
def test_sum_edges():
    h = StreamHist().update(0).update(10)
    assert h.sum(5) == 1
    assert h.sum(0) == 0.5
    assert h.sum(10) == 2