# 15.4. Computing exact probabilities and manipulating random variables

https://ipython-books.github.io/154-computing-exact-probabilities-and-manipulating-random-variables/

### Ref

* SymPy stats at http://docs.sympy.org/latest/modules/stats.html
* Probability lectures on Awesome Math, at https://github.com/rossant/awesome-math/#probability-theory
* Statistics lectures on Awesome Math, at https://github.com/rossant/awesome-math/#statistics


```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))))
```


```python

```


```python

```


```python

```

da2ae928217af7382305208772c07544656afd86
ipynb
Jupyter Notebook
chapter15_symbolic/04_stats.ipynb
wgong/cookbook-2nd-code
8ca2e5b3c90fee6605f4155e6b9dfb783ce46807
MIT
chapter15_symbolic/04_stats.ipynb
wgong/cookbook-2nd-code
8ca2e5b3c90fee6605f4155e6b9dfb783ce46807
MIT
chapter15_symbolic/04_stats.ipynb
wgong/cookbook-2nd-code
8ca2e5b3c90fee6605f4155e6b9dfb783ce46807
MIT
Qwen/Qwen-72B
1. YES
2. YES