add hw 7
This commit is contained in:
20
pracs/prac7/scripts/2.py
Normal file
20
pracs/prac7/scripts/2.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
# Задача 2: гипергеометрическое распределение
|
||||
xi2 = [0, 1, 2]
|
||||
P2 = [1 / 45, 16 / 45, 28 / 45]
|
||||
F2 = np.cumsum(P2)
|
||||
|
||||
plt.figure(figsize=(7, 5))
|
||||
plt.bar(xi2, P2, color="skyblue", alpha=0.7, label="Вероятности")
|
||||
plt.step(xi2, F2, where="post", color="orange", label="Функция распределения")
|
||||
plt.scatter(xi2, F2, color="red")
|
||||
plt.title("Задача 2: гипергеометрическое распределение")
|
||||
plt.xlabel("xi")
|
||||
plt.ylabel("P / F")
|
||||
plt.xticks(xi2)
|
||||
plt.legend()
|
||||
plt.grid(axis="y", linestyle="--", alpha=0.6)
|
||||
plt.tight_layout()
|
||||
plt.savefig("2.png")
|
||||
Reference in New Issue
Block a user