48 lines
956 B
Python
48 lines
956 B
Python
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
a = np.array([0, 1, 2, 3, 4, 5, 6])
|
|
h = np.array([83, 25, 28, 18, 12, 10, 2])
|
|
|
|
n = np.sum(h)
|
|
|
|
pmf = h / n
|
|
|
|
H_abs = h.cumsum()
|
|
F_rel = pmf.cumsum()
|
|
|
|
plt.figure()
|
|
plt.bar(a, h)
|
|
plt.title('Relative Häufigkeit (PMF)')
|
|
plt.xlabel('Anzahl der Defekte')
|
|
plt.ylabel('Absolute Häufigkeit')
|
|
plt.xticks(a)
|
|
plt.tight_layout()
|
|
|
|
plt.figure()
|
|
plt.bar(a, pmf)
|
|
plt.title('Relative Häufigkeit (PMF)')
|
|
plt.xlabel('Anzahl der Defekte')
|
|
plt.ylabel('Relative Häufigkeit')
|
|
plt.xticks(a)
|
|
plt.tight_layout()
|
|
|
|
plt.figure()
|
|
plt.step(a, H_abs, where="post")
|
|
plt.title("Absolute Verteilungsfunktion (CDF)")
|
|
plt.xlabel("a_i")
|
|
plt.ylabel("H_i = Σ h_i")
|
|
plt.xticks(a)
|
|
plt.tight_layout()
|
|
|
|
# 4) CDF relativa (right-continuous)
|
|
plt.figure()
|
|
plt.step(a, F_rel, where="post")
|
|
plt.title("Relative Verteilungsfunktion (CDF)")
|
|
plt.xlabel("a_i")
|
|
plt.ylabel("F_i = Σ P(X=a_i)")
|
|
plt.xticks(a)
|
|
plt.ylim(0, 1.05)
|
|
plt.tight_layout()
|
|
|
|
plt.show() |