Well, I was a bit surprised too, but the stats module apparently does so, 
as shown in this example:

In [1]: from sympy.stats import *

In [2]: var('sigma', positive=True)
Out[2]: σ

In [3]: N = Normal('X', mu, sigma)

In [6]: P(N**2>1, evaluate=False)
Out[6]: 
(-∞, -1) ∪ (1, ∞)                     
        ⌠                             
        ⎮                        2    
        ⎮                -(z - μ)     
        ⎮                ──────────   
        ⎮                      2      
        ⎮           ___     2⋅σ       
        ⎮         ╲╱ 2 ⋅ℯ             
        ⎮         ───────────────── dz
        ⎮                 ___         
        ⎮             2⋅╲╱ π ⋅σ       
        ⌡ 


In [7]: srepr(P(N**2>1, evaluate=False))
Out[7]: "Integral(Mul(Rational(1, 2), Pow(Integer(2), Rational(1, 2)), 
Pow(pi, Rational(-1, 2)), Pow(Symbol('sigma'), Integer(-1)), 
exp(Mul(Integer(-1), Rational(1, 2), Pow(Symbol('sigma'), Integer(-2)), 
Pow(Add(Dummy('z'), Mul(Integer(-1), Symbol('mu'))), Integer(2))))), 
Tuple(Dummy('z'), Union(Interval(-oo, Integer(-1), S.true, S.true), 
Interval(Integer(1), oo, S.true, S.true))))"


Apart the fact that such an integral looks wrong to me, i.e. there is no 
account for the random variable being squared (or am I missing something?), 
it looks like SymPy is OK with intervals, but not with unions of intervals:

https://github.com/sympy/sympy/blob/9242d31f6d31a1d9c3464264a5a6e61eab8acfb8/sympy/concrete/expr_with_limits.py#L37

That's the point where an Interval gets parsed by the integration algorithm.

I think it's an easy fix to add the processing for unions of intervals.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/230fe8c3-a834-4074-920d-435a2687be36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to