Skip to content
Snippets Groups Projects
Commit 7a3b412f authored by Tom van Woudenberg's avatar Tom van Woudenberg
Browse files

Create solution.ipynb

parent a91576de
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import sympy as sym
```
%% Cell type:code id: tags:
``` python
x = sym.symbols('x')
#beta = sym.sqrt(6*16.797**2/sym.pi**2)
#mu = 35.724 - 0.577*beta
beta , mu = sym.symbols('beta mu')
F_gumbel = sym.exp(-sym.exp(-(x-mu)/beta))
display(F_gumbel)
```
%% Output
$\displaystyle e^{- e^{\frac{\mu - x}{\beta}}}$
%% Cell type:code id: tags:
``` python
Prob_non_exc = sym.symbols('Prob_non_exc')
eq1 = sym.Eq(Prob_non_exc,F_gumbel)
display(eq1)
x_sol = sym.solve(eq1, x)[0]
display(x_sol)
```
%% Output
$\displaystyle Prob_{non exc} = e^{- e^{\frac{\mu - x}{\beta}}}$
$\displaystyle - \beta \log{\left(e^{- \frac{\mu}{\beta}} \log{\left(\frac{1}{Prob_{non exc}} \right)} \right)}$
%% Cell type:code id: tags:
``` python
Prob_non_exc_list = [1/773, 0.25, 0.5, 0.75, 772/773]
for i in range(len(Prob_non_exc_list)):
display(x_sol.subs({beta:13.097, mu:28.167, Prob_non_exc:Prob_non_exc_list[i]}))
```
%% Output
$\displaystyle 3.35265348709722$
$\displaystyle 23.8890710970645$
$\displaystyle 32.9672197208581$
$\displaystyle 44.4845434425937$
$\displaystyle 115.25722858997$
%% Cell type:code id: tags:
``` python
f_gumbel = sym.diff(F_gumbel, x)
display(f_gumbel)
```
%% Output
$\displaystyle \frac{e^{\frac{\mu - x}{\beta}} e^{- e^{\frac{\mu - x}{\beta}}}}{\beta}$
$\displaystyle \frac{e^{\frac{\mu}{\beta}} \int\limits_{-\infty}^{x} e^{- \frac{x}{\beta}} e^{- e^{\frac{\mu}{\beta}} e^{- \frac{x}{\beta}}}\, dx}{\beta}$
exp(mu/beta)*Integral(exp(-x/beta)*exp(-exp(mu/beta)*exp(-x/beta)), (x, -oo, x))/beta
%% Cell type:code id: tags:
``` python
f_gumbel_2 = sym.exp(-((x-mu)/beta+sym.exp(-(x-mu)/beta)))/beta
display(f_gumbel_2)
```
%% Output
$\displaystyle \frac{e^{- e^{\frac{\mu - x}{\beta}} - \frac{- \mu + x}{\beta}}}{\beta}$
%% Cell type:code id: tags:
``` python
display(f_gumbel-f_gumbel_2)
display(sym.simplify(f_gumbel-f_gumbel_2))
```
%% Output
$\displaystyle \frac{e^{\frac{\mu - x}{\beta}} e^{- e^{\frac{\mu - x}{\beta}}}}{\beta} - \frac{e^{- e^{\frac{\mu - x}{\beta}} - \frac{- \mu + x}{\beta}}}{\beta}$
$\displaystyle 0$
%% Cell type:markdown id: tags:
$$\begin{equation}
f(x)=
\begin{cases}
0.1 & \text{if } 0 < x < 3.6 \\
2(x-5) & 5 < x < 5.8 \\
0 & \text{elsewhere}
\end{cases}
\end{equation}$$
%% Cell type:code id: tags:
``` python
f = sym.Piecewise((0, x< 0), (0.1 , x < 3.6), (0, x < 5), (2*(x-5),x<5.8), (0, True))
sym.plot(f, (x,-1,6));
```
%% Output
%% Cell type:code id: tags:
``` python
F = sym.integrate(f, x)
display(F)
sym.plot(F, (x,-1,6));
```
%% Output
$\displaystyle \begin{cases} 0 & \text{for}\: x < 0 \\0.1 x & \text{for}\: x < 3.6 \\0.36 & \text{for}\: x < 5 \\x^{2} - 10 x + 25.36 & \text{for}\: x < 5.8 \\1.0 & \text{otherwise} \end{cases}$
%% Cell type:code id: tags:
``` python
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment