-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfisher_f.py
35 lines (27 loc) · 917 Bytes
/
fisher_f.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
35
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import f
def save_to(directory: str, extension: str):
def y(x, dfn, dfd):
y = f.pdf(x, dfn, dfd)
y[y > 2.3] = np.nan
return y
# Degrees of freedom for the distribution
d1_d2 = [(1, 1), (2, 1), (3, 1), (10, 1), (10, 10), (100, 100)]
# Possible 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 the degrees of freedom
for m, n in d1_d2:
ax.plot(x, y(x, m, n), label=f'm = {m}, n = {n}')
# Adding title and labels
ax.set_title('F-distribution')
ax.set_xlabel('F-statistic')
ax.set_ylabel('Probability density')
# Adding a legend
ax.legend()
ax.grid()
ax.margins(x=0, y=0)
plt.savefig(f"{directory}/fisher_f.{extension}")
plt.close()