Wow, I didn't know integrate supported Intervals.
If we are going to
support sets, we might as well support all of them (at least
unevaluated). A union of intervals is easy if the values are
computable (i.e., if you can determine if the union is disjoint).
Otherwise, it's complicated. Integrate(1, (x, Union(Interval(a, b),
Interval(c, d)))) depends on the relative order of a, b, c, and d.
Even the current integrate(1, (x, Interval(a, b))) is wrong if b > a.
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))))"
--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6LbcosAeX6FeM0y%2Bb%3D50yrpDUK%3DiVpKhsNqKEh7A46W5A%40mail.gmail.com.