Comment #1 on issue 3711 by julien.r...@gmail.com: probability() should handle union and intersection of conditions as well as point conditions
http://code.google.com/p/sympy/issues/detail?id=3711

You are using the wrong syntax to represent the (in)equalities:

1) `X = 2` used in the call to a function means a keyword argument, not an equality. 2) python's `or` and `and` are short circuit operators, not suitable for symbolic.

You need to use the symbolic `Eq`, `Or`, and `And` instead. Nevertheless, when I do that, there is still a bug with calculating the probability for the normal distribution:

from sympy import And, Or, Eq
from sympy.stats import Die, P, Normal
X = Die('X', 6)
Y = Normal('Y', 0, 1)
P(Eq(X, 2))
1/6
P(Eq(Y, 0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy/stats/rv.py", line 573, in probability
    return pspace(condition).probability(condition, **kwargs)
  File "sympy/stats/crv.py", line 305, in probability
    return integrate(pdf(z), (z, domain.set), **kwargs)
  File "sympy/utilities/decorator.py", line 25, in threaded_func
    return func(expr, *args, **kwargs)
  File "sympy/integrals/integrals.py", line 1481, in integrate
return integral.doit(deep=False, meijerg=meijerg, conds=conds, risch=risch)
  File "sympy/integrals/integrals.py", line 779, in doit
    function = antideriv._eval_interval(x, a, b)
  File "sympy/core/expr.py", line 662, in _eval_interval
    B = self.subs(x, b)
  File "sympy/core/basic.py", line 878, in subs
    rv = rv._subs(old, new)
  File "sympy/core/cache.py", line 92, in wrapper
    func_cache_it_cache[k] = r = func(*args, **kw_args)
  File "sympy/core/basic.py", line 977, in _subs
    rv = fallback(self, old, new)
  File "sympy/core/basic.py", line 964, in fallback
    arg = arg._subs(old, new, **hints)
  File "sympy/core/cache.py", line 92, in wrapper
    func_cache_it_cache[k] = r = func(*args, **kw_args)
  File "sympy/core/basic.py", line 977, in _subs
    rv = fallback(self, old, new)
  File "sympy/core/basic.py", line 969, in fallback
    return self.func(*args)
  File "sympy/core/cache.py", line 92, in wrapper
    func_cache_it_cache[k] = r = func(*args, **kw_args)
  File "sympy/core/function.py", line 282, in __new__
    result = super(Function, cls).__new__(cls, *args, **options)
  File "sympy/core/cache.py", line 92, in wrapper
    func_cache_it_cache[k] = r = func(*args, **kw_args)
  File "sympy/core/function.py", line 128, in __new__
    evaluated = cls.eval(*args)
  File "sympy/functions/special/error_functions.py", line 116, in eval
    t = arg.extract_multiplicatively(S.ImaginaryUnit)
  File "sympy/core/expr.py", line 1852, in extract_multiplicatively
    newarg = arg.extract_multiplicatively(c)
AttributeError: 'FiniteSet' object has no attribute 'extract_multiplicatively'
P(Or(X > 2, X < 3))
1
P(And(X > 3, X > 2))
1/2


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to