24 lines
725 B
Python
24 lines
725 B
Python
from math import exp, factorial
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
# Задача 4: распределение Пуассона
|
|
lambda4 = 2
|
|
xi4 = list(range(0, 11))
|
|
P4 = [lambda4**k * exp(-lambda4) / factorial(k) for k in xi4]
|
|
F4 = np.cumsum(P4)
|
|
|
|
plt.figure(figsize=(7, 5))
|
|
plt.bar(xi4, P4, color="plum", alpha=0.7, label="Вероятности")
|
|
plt.step(xi4, F4, where="post", color="orange", label="Функция распределения")
|
|
plt.scatter(xi4, F4, color="red")
|
|
plt.title("Задача 4: распределение Пуассона")
|
|
plt.xlabel("xi")
|
|
plt.ylabel("P / F")
|
|
plt.xticks(xi4)
|
|
plt.legend()
|
|
plt.grid(axis="y", linestyle="--", alpha=0.6)
|
|
plt.tight_layout()
|
|
plt.savefig("4.png")
|