This commit is contained in:
nik
2025-10-20 14:39:37 +03:00
parent eca3559e24
commit f256237ed2
11 changed files with 322 additions and 0 deletions

34
pracs/prac7/scripts/1.py Normal file
View File

@@ -0,0 +1,34 @@
import matplotlib.pyplot as plt
# Значения случайной величины
xi = [0, 1, 2, 3, 4]
# Вероятности
P = [16 / 81, 32 / 81, 24 / 81, 8 / 81, 1 / 81]
# Функция распределения
F = []
cum = 0
for p in P:
cum += p
F.append(cum)
plt.figure(figsize=(12, 5))
# График вероятностей
plt.subplot(1, 2, 1)
plt.bar(xi, P, color="skyblue")
plt.xlabel("xi")
plt.ylabel("P(xi)")
plt.title("Ряд распределения")
# График функции распределения
plt.subplot(1, 2, 2)
plt.step(xi, F, where="post", color="orange")
plt.scatter(xi, F, color="red")
plt.xlabel("xi")
plt.ylabel("F(xi)")
plt.title("Функция распределения")
plt.tight_layout()
plt.savefig("1.png")