# 15.4. Computing exact probabilities and manipulating random variables


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


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


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


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


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


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


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


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


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


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


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


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


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

96036cffe50a9f994152ad9cad1027b2dbe501a0
ipynb
Jupyter Notebook
001-Jupyter/001-Tutorials/002-IPython-Cookbook/chapter15_symbolic/04_stats.ipynb
jhgoebbert/jupyter-jsc-notebooks
bcd08ced04db00e7a66473b146f8f31f2e657539
BSD-3-Clause
001-Jupyter/001-Tutorials/002-IPython-Cookbook/chapter15_symbolic/04_stats.ipynb
jhgoebbert/jupyter-jsc-notebooks
bcd08ced04db00e7a66473b146f8f31f2e657539
BSD-3-Clause
001-Jupyter/001-Tutorials/002-IPython-Cookbook/chapter15_symbolic/04_stats.ipynb
jhgoebbert/jupyter-jsc-notebooks
bcd08ced04db00e7a66473b146f8f31f2e657539
BSD-3-Clause
2022-01-13T18:49:12.000Z
2022-01-13T18:49:12.000Z
Qwen/Qwen-72B
1. YES
2. YES