-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrechet.py
34 lines (27 loc) · 1008 Bytes
/
frechet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import invweibull
def save_to(directory: str, extension: str):
def y(x, shape, loc, scale):
return invweibull.pdf(x, shape, loc=loc, scale=scale)
# Inputs for the distribution
inputs = [(0, 1, 1), (1, 1, 1), (0, 0.5, 1), (0, 2, 1), (0, 1, 0.35), (0, 1, 2)]
# x values for the distribution
x = np.linspace(0, 5, 1000)
# Creating the figure and the axis
fig, ax = plt.subplots()
# Plotting the PDF for each value of a
for loc, scale, shape in inputs:
ax.plot(x, y(x, shape, loc, scale), label=f'μ = {loc}, σ = {scale}, α = {shape}')
# Adding title and labels
ax.set_title('Fréchet distribution')
ax.set_xlabel('x')
ax.set_ylabel('Probability density')
# Adding a legend
ax.legend()
ax.grid()
ax.margins(x=0, y=0)
ymin, ymax = ax.get_ylim()
ax.set_ylim(ymin, ymax * 1.05)
plt.savefig(f"{directory}/frechet.{extension}")
plt.close()