New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P(X < -1) of ExponentialDistribution #10003

Closed
gxyd opened this Issue Oct 19, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@gxyd
Copy link
Member

gxyd commented Oct 19, 2015

>>> from sympy import *
>>> from sympy.stats import Exponential, Gamma, P, pspace, Normal, Uniform
>>> X = Exponential('X', 3)
>>> P(X < -1)
AttributeError                            Traceback (most recent call last)
<ipython-input-168-7d38f8bb52c5> in <module>()
----> 1 P(X < -1)

/home/gxyd/Public/sympy/sympy/stats/rv.py in probability(condition, given_condition, numsamples, evaluate, **kwargs)
    621     result = pspace(condition).probability(condition, **kwargs)
    622     if evaluate and hasattr(result, 'doit'):
--> 623         return result.doit()
    624     else:
    625         return result

/home/gxyd/Public/sympy/sympy/integrals/integrals.py in doit(self, **hints)
    525                     else:
    526                         try:
--> 527                             function = antideriv._eval_interval(x, a, b)
    528                         except NotImplementedError:
    529                             # This can happen if _eval_interval depends in a

/home/gxyd/Public/sympy/sympy/core/expr.py in _eval_interval(self, x, a, b)
    778             B = 0
    779         else:
--> 780             B = self.subs(x, b)
    781             if B.has(S.NaN, S.Infinity, S.NegativeInfinity, S.ComplexInfinity):
    782                 B = limit(self, x, b)

/home/gxyd/Public/sympy/sympy/core/basic.py in subs(self, *args, **kwargs)
    893             rv = self
    894             for old, new in sequence:
--> 895                 rv = rv._subs(old, new, **kwargs)
    896                 if not isinstance(rv, Basic):
    897                     break

/home/gxyd/Public/sympy/sympy/core/cache.py in wrapper(*args, **kwargs)
     91             def wrapper(*args, **kwargs):
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
     95                     retval = func(*args, **kwargs)

/usr/lib/python3.4/functools.py in wrapper(*args, **kwds)
    470                         hits += 1
    471                         return result
--> 472                 result = user_function(*args, **kwds)
    473                 with lock:
    474                     if key in cache:

/home/gxyd/Public/sympy/sympy/core/basic.py in _subs(self, old, new, **hints)
   1007         rv = self._eval_subs(old, new)
   1008         if rv is None:
-> 1009             rv = fallback(self, old, new)
   1010         return rv
   1011 

/home/gxyd/Public/sympy/sympy/core/basic.py in fallback(self, old, new)
    979                 if not hasattr(arg, '_eval_subs'):
    980                     continue
--> 981                 arg = arg._subs(old, new, **hints)
    982                 if not _aresame(arg, args[i]):
    983                     hit = True

/home/gxyd/Public/sympy/sympy/core/cache.py in wrapper(*args, **kwargs)
     91             def wrapper(*args, **kwargs):
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
     95                     retval = func(*args, **kwargs)

/usr/lib/python3.4/functools.py in wrapper(*args, **kwds)
    470                         hits += 1
    471                         return result
--> 472                 result = user_function(*args, **kwds)
    473                 with lock:
    474                     if key in cache:

/home/gxyd/Public/sympy/sympy/core/basic.py in _subs(self, old, new, **hints)
   1007         rv = self._eval_subs(old, new)
   1008         if rv is None:
-> 1009             rv = fallback(self, old, new)
   1010         return rv
   1011 

/home/gxyd/Public/sympy/sympy/core/basic.py in fallback(self, old, new)
    979                 if not hasattr(arg, '_eval_subs'):
    980                     continue
--> 981                 arg = arg._subs(old, new, **hints)
    982                 if not _aresame(arg, args[i]):
    983                     hit = True

/home/gxyd/Public/sympy/sympy/core/cache.py in wrapper(*args, **kwargs)
     91             def wrapper(*args, **kwargs):
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
     95                     retval = func(*args, **kwargs)

/usr/lib/python3.4/functools.py in wrapper(*args, **kwds)
    470                         hits += 1
    471                         return result
--> 472                 result = user_function(*args, **kwds)
    473                 with lock:
    474                     if key in cache:

/home/gxyd/Public/sympy/sympy/core/basic.py in _subs(self, old, new, **hints)
   1007         rv = self._eval_subs(old, new)
   1008         if rv is None:
-> 1009             rv = fallback(self, old, new)
   1010         return rv
   1011 

/home/gxyd/Public/sympy/sympy/core/basic.py in fallback(self, old, new)
    984                     args[i] = arg
    985             if hit:
--> 986                 rv = self.func(*args)
    987                 hack2 = hints.get('hack2', False)
    988                 if hack2 and self.is_Mul and not rv.is_Mul:  # 2-arg hack

/home/gxyd/Public/sympy/sympy/core/cache.py in wrapper(*args, **kwargs)
     91             def wrapper(*args, **kwargs):
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
     95                     retval = func(*args, **kwargs)

/usr/lib/python3.4/functools.py in wrapper(*args, **kwds)
    470                         hits += 1
    471                         return result
--> 472                 result = user_function(*args, **kwds)
    473                 with lock:
    474                     if key in cache:

/home/gxyd/Public/sympy/sympy/core/operations.py in __new__(cls, *args, **options)
     39             return args[0]
     40 
---> 41         c_part, nc_part, order_symbols = cls.flatten(args)
     42         is_commutative = not nc_part
     43         obj = cls._from_args(c_part + nc_part, is_commutative)

/home/gxyd/Public/sympy/sympy/core/mul.py in flatten(cls, seq)
    179             assert not a is S.One
    180             if not a.is_zero and a.is_Rational:
--> 181                 r, b = b.as_coeff_Mul()
    182                 if b.is_Add:
    183                     if r is not S.One:  # 2-arg hack

AttributeError: 'EmptySet' object has no attribute 'as_coeff_Mul'

I guess this should return S.Zero, instead of an AttributeError.

gxyd pushed a commit to gxyd/sympy that referenced this issue Oct 19, 2015

Gaurav Dhingra

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 16, 2016

Probability for empty set returns S.Zero
fixes sympy/sympy#10003

Signed-off-by: Sergey B Kirpichev <skirpichev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment