Ejemplo n.º 1
0
def test_mode1():
    """ Test mode 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, mode(d)[0][0] in [floor((n+1)*p), floor((n+1)*p)-1]
Ejemplo n.º 2
0
def test_mode2():
    """ Test mode on a generic distribution """
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1 / 8, 1 / 8, 3 / 8, 3 / 8])
    modes = [np.array([2, 3]), np.array([1])]
    for m1, m2 in zip(mode(d), modes):
        assert np.allclose(m1, m2)
Ejemplo n.º 3
0
def test_mode1(n, p):
    """ Test mode on binomial distribution """
    d = binomial(n, p)
    assert mode(d)[0][0] in [floor((n + 1) * p), floor((n + 1) * p) - 1]
Ejemplo n.º 4
0
def test_mode2():
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1/8, 1/8, 3/8, 3/8])
    modes = [np.array([2, 3]), np.array([1])]
    for m1, m2 in zip(mode(d), modes):
        assert_array_almost_equal(m1, m2)
Ejemplo n.º 5
0
def test_mode1():
    ns = range(2, 10)
    ps = np.linspace(0, 1, 11)
    for n, p in product(ns, ps):
        d = binomial(n, p)
        assert(mode(d)[0][0] in [floor((n+1)*p), floor((n+1)*p)-1])
Ejemplo n.º 6
0
def test_mode2():
    """ Test mode on a generic distribution """
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1/8, 1/8, 3/8, 3/8])
    modes = [np.array([2, 3]), np.array([1])]
    for m1, m2 in zip(mode(d), modes):
        assert np.allclose(m1, m2)
Ejemplo n.º 7
0
def test_mode1(n, p):
    """ Test mode on binomial distribution """
    d = binomial(n, p)
    assert mode(d)[0][0] in [floor((n+1)*p), floor((n+1)*p)-1]
Ejemplo n.º 8
0
def test_mode2():
    """ Test mode on a generic distribution """
    d = D([(0, 0), (1, 0), (2, 1), (3, 1)], [1/8, 1/8, 3/8, 3/8])
    modes = [np.array([2, 3]), np.array([1])]
    for m1, m2 in zip(mode(d), modes):
        yield assert_array_almost_equal, m1, m2