def test_coins(): C, D = Coin('C'), Coin('D') H, T = symbols('H, T') assert P(Eq(C, D)) == S.Half assert density(Tuple(C, D)) == {(H, H): S.One/4, (H, T): S.One/4, (T, H): S.One/4, (T, T): S.One/4} assert dict(density(C).items()) == {H: S.Half, T: S.Half} F = Coin('F', S.One/10) assert P(Eq(F, H)) == S(1)/10 d = pspace(C).domain assert d.as_boolean() == Or(Eq(C.symbol, H), Eq(C.symbol, T)) raises(ValueError, lambda: P(C > D)) # Can't intelligently compare H to T
def test_coins(): C, D = Coin("C"), Coin("D") H, T = symbols("H, T") assert P(Eq(C, D)) == S.Half assert density(Tuple(C, D)) == { (H, H): Rational(1, 4), (H, T): Rational(1, 4), (T, H): Rational(1, 4), (T, T): Rational(1, 4), } assert dict(density(C).items()) == {H: S.Half, T: S.Half} F = Coin("F", Rational(1, 10)) assert P(Eq(F, H)) == Rational(1, 10) d = pspace(C).domain assert d.as_boolean() == Or(Eq(C.symbol, H), Eq(C.symbol, T)) raises(ValueError, lambda: P(C > D)) # Can't intelligently compare H to T
def test_coins(): C, D = Coin(), Coin() H, T = sorted(Density(C).keys()) assert P(Eq(C, D)) == S.Half assert Density(Tuple(C, D)) == { (H, H): S.One / 4, (H, T): S.One / 4, (T, H): S.One / 4, (T, T): S.One / 4 } assert Density(C) == {H: S.Half, T: S.Half} E = Coin(S.One / 10) assert P(Eq(E, H)) == S(1) / 10 d = pspace(C).domain assert d.as_boolean() == Or(Eq(C.symbol, H), Eq(C.symbol, T)) raises(ValueError, "P(C>D)") # Can't intelligently compare H to T