I am trying to use the stats module to calculate probabilities for a normal distributed RV.
Problem is, I sometimes get "TypeError: cannot determine truth value of -oo < -inf".
Weird thing is, the error is not always reproducible between (ipython) sessions (see below)
Python 3.3.2 (default, Dec 4 2014, 12:49:00)
Type "copyright", "credits" or "license" for more information.
IPython 2.3.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import sympy; sympy.__version__
Out[1]: '0.7.6'
In [2]: from sympy.stats import Normal, P
In [3]: N0 = Normal('N0', 0, 1)
In [4]: P(N0 < 1.1001)
Out[4]: erf(0.55005*sqrt(2))/2 + erf(+inf*sqrt(2))/2
In [5]: P(N0 <= 1.1001)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-b60ca102def7> in <module>()
----> 1 P(N0 <= 1.1001)
/usr/lib/python3.3/site-packages/sympy/stats/rv.py in probability(condition, given_condition, numsamples, evaluate, **kwargs)
615
616 # Otherwise pass work off to the ProbabilitySpace
--> 617 result = pspace(condition).probability(condition, **kwargs)
618 if evaluate and hasattr(result, 'doit'):
619 return result.doit()
/usr/lib/python3.3/site-packages/sympy/stats/crv.py in probability(self, condition, **kwargs)
294 # Univariate case can be handled by where
295 try:
--> 296 domain = self.where(condition)
297 rv = [rv for rv in self.values if rv.symbol == domain.symbol][0]
298 # Integrate out all other random variables
/usr/lib/python3.3/site-packages/sympy/stats/crv.py in where(self, condition)
320 rv = tuple(rvs)[0]
321 interval = reduce_rational_inequalities_wrap(condition, rv)
--> 322 interval = interval.intersect(self.domain.set)
323 return SingleContinuousDomain(rv.symbol, interval)
324
/usr/lib/python3.3/site-packages/sympy/sets/sets.py in intersect(self, other)
93
94 """
---> 95 return Intersection(self, other)
96
97 def intersection(self, other):
/usr/lib/python3.3/site-packages/sympy/sets/sets.py in __new__(cls, *args, **kwargs)
1285 # Reduce sets using known rules
1286 if evaluate:
-> 1287 return Intersection.reduce(args)
1288
1289 args = list(ordered(args, Set._infimum_key))
/usr/lib/python3.3/site-packages/sympy/sets/sets.py in reduce(args)
1370 new_args = False
1371 for t in args - set((s,)):
-> 1372 new_set = s._intersect(t)
1373 # This returns None if s does not know how to intersect
1374 # with t. Returns the newly intersected set otherwise
/usr/lib/python3.3/site-packages/sympy/sets/sets.py in _intersect(self, other)
818 if self.start <= other.end and other.start <= self.end:
819 # Get topology right.
--> 820 if self.start < other.start:
821 start = other.start
822 left_open = other.left_open
/usr/lib/python3.3/site-packages/sympy/core/relational.py in __nonzero__(self)
101
102 def __nonzero__(self):
--> 103 raise TypeError("cannot determine truth value of\n%s" % self)
104
105 __bool__ = __nonzero__
TypeError: cannot determine truth value of
-oo < -inf