Beispiel #1
0
def test_median1():
    """ Test median on binomial distribution """
    ns = range(2, 10)
    ps = np.linspace(0, 1, 11)
    for n, p in product(ns, ps):
        d = binomial(n, p)
        yield assert_true, median(d) in [floor(n*p), n*p, ceil(n*p)]
Beispiel #2
0
def test_median2():
    """ Test median on a generic distribution """
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1 / 8, 1 / 8, 3 / 8, 3 / 8])
    assert np.allclose(median(d), [2, 1])
Beispiel #3
0
def test_median1(n, p):
    """ Test median on binomial distribution """
    d = binomial(n, p)
    assert median(d) in [floor(n * p), n * p, ceil(n * p)]
Beispiel #4
0
def test_median2():
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1/8, 1/8, 3/8, 3/8])
    assert_array_almost_equal(median(d), [2, 1])
Beispiel #5
0
def test_median1():
    ns = range(2, 10)
    ps = np.linspace(0, 1, 11)
    for n, p in product(ns, ps):
        d = binomial(n, p)
        assert(median(d) in [floor(n*p), n*p, ceil(n*p)])
Beispiel #6
0
def test_median2():
    """ Test median on a generic distribution """
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1/8, 1/8, 3/8, 3/8])
    assert np.allclose(median(d), [2, 1])
Beispiel #7
0
def test_median1(n, p):
    """ Test median on binomial distribution """
    d = binomial(n, p)
    assert median(d) in [floor(n*p), n*p, ceil(n*p)]
Beispiel #8
0
def test_median2():
    """ Test median on a generic distribution """
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1/8, 1/8, 3/8, 3/8])
    assert_array_almost_equal(median(d), [2, 1])