Ejemplo n.º 1
0
def test_amax_pb_binom():
    """Compare the amax function with the binomial limit case."""
    # For equal probabilites p_j, the Poisson Binomial distribution reduces
    # to the Binomial one:
    p = [0.5, 0.5, 0.5, 0.5]
    pb = PoiBin(p)
    bn = binom(n=4, p=p[0])

    cases = [0, 1, 2, 3, 4]

    # Compare to four digits behind the comma
    assert int(np.amax(bn.pmf(cases)) * 10000) == int(pb.amax() * 10000)

    # For different probabilities p_j, the Poisson Binomial distribution and
    # the Binomial distribution are different:
    pb = PoiBin([0.5, 0.5, 0.8, 0.8])
    bn = binom(4, p=0.5)
    assert int(np.amax(bn.pmf(cases)) * 10000) != int(pb.amax() * 10000)
Ejemplo n.º 2
0
def test_argmax():
    """Test amax function."""
    p = [0.1, 0.1, 0.1, 0.9, 0.9, 0.9]
    pb = PoiBin(p)
    assert (pb.amax() - np.array([0.59122])) < 4 * np.finfo(float).eps