```python
from sympy import *
from sympy.stats import *
from sympy.utilities.lambdify import *
import math
```


```python
x, a, b = var("x a b")
f = (x-3)/2
i = integrate(f, (x, a, b))
i
```




$\displaystyle - \frac{a^{2}}{4} + \frac{3 a}{2} + \frac{b^{2}}{4} - \frac{3 b}{2}$




```python
i.subs({a: 3, b: 5}) # area da curva deve ser 1
```




$\displaystyle 1$




```python
i.subs({a: 3.3, b: 4}) # medindo a probabilidade
```




$\displaystyle 0.2275$




```python
mu = integrate(x*f, (x, a, b)) # media
mu
```




$\displaystyle - \frac{a^{3}}{6} + \frac{3 a^{2}}{4} + \frac{b^{3}}{6} - \frac{3 b^{2}}{4}$




```python
Var = integrate((x**2)*f) - mu**2 # varianca
Var
```




$\displaystyle \frac{x^{4}}{8} - \frac{x^{3}}{2} - \left(- \frac{a^{3}}{6} + \frac{3 a^{2}}{4} + \frac{b^{3}}{6} - \frac{3 b^{2}}{4}\right)^{2}$




```python
x = var('x')
f = Piecewise(((1/40)*(x-4), And(Ge(x, 8), Lt(x, 10))), (3/20, And(Ge(x, 10), Le(x, 15))), (0, True))
f
```




$\displaystyle \begin{cases} 0.025 x - 0.1 & \text{for}\: x \geq 8 \wedge x < 10 \\0.15 & \text{for}\: x \geq 10 \wedge x \leq 15 \\0 & \text{otherwise} \end{cases}$




```python
mu = integrate(x*f, (x, a, b))
mu.subs({ a: 8, b: 15})
```




$\displaystyle 11.6416666666667$




```python
E2 = integrate((x**2)*f, (x, a, b))
Var = E2 - (mu**2)
Var.subs({ a: 8, b: 15})
```




$\displaystyle 3.85493055555557$




```python
integrate(f, (x, a, b)).subs({ a: 9, b: 12 })
```




$\displaystyle 0.4375$




```python
integrate(f, (x, a, b)).subs({ a: 8, b: 14 }) / integrate(f, (x, a, b)).subs({ a: 8, b: oo })
```




$\displaystyle 0.850000000000001$



b5d707bc51e085588b6a1e081b6c4565171a40f1
ipynb
Jupyter Notebook
probabilidade_v_a_continua.ipynb
GrrriiiM/estudos-python
b171fc8f6f29b8dcec80051ac1ce86edd34e0e57
MIT
probabilidade_v_a_continua.ipynb
GrrriiiM/estudos-python
b171fc8f6f29b8dcec80051ac1ce86edd34e0e57
MIT
probabilidade_v_a_continua.ipynb
GrrriiiM/estudos-python
b171fc8f6f29b8dcec80051ac1ce86edd34e0e57
MIT
Qwen/Qwen-72B
1. YES
2. YES