# 15.4. Computing exact probabilities and manipulating random variables


```
from sympy import *
from sympy.stats import *
init_printing()
```


```
X, Y = Die('X', 6), Die('Y', 6)
```


```
P(Eq(X, 3))
```


```
P(X > 3)
```


```
P(X > Y)
```


```
P(X + Y > 6, X < 5)
```


```
Z = Normal('Z', 0, 1)  # Gaussian variable
```


```
P(Z > pi)
```


```
E(Z**2), variance(Z**2)
```


```
f = density(Z)
```


```
var('x')
f(x)
```


```
%matplotlib inline
plot(f(x), (x, -6, 6))
```


```
Eq(Integral(f(x), (x, pi, oo)),
   simplify(integrate(f(x), (x, pi, oo))))
```

07f6c3340195b30d4a94a941eca6ece05de8c607
ipynb
Jupyter Notebook
chapter15_symbolic/04_stats.ipynb
guoci/cookbook-2nd-code
1e6d8b1b66fcffa6362b13893bbd0e43f2829cb6
MIT
2018-02-01T09:16:45.000Z
2022-03-03T17:47:59.000Z
chapter15_symbolic/04_stats.ipynb
dnzengou/cookbook-2nd-code
85128694cdb9206b4325f95fe0060e01cf72e7f5
MIT
2019-03-11T09:47:21.000Z
2022-01-11T06:32:00.000Z
chapter15_symbolic/04_stats.ipynb
dnzengou/cookbook-2nd-code
85128694cdb9206b4325f95fe0060e01cf72e7f5
MIT
2018-02-13T03:17:05.000Z
2022-03-18T21:04:45.000Z
Qwen/Qwen-72B
1. YES
2. YES