import scipy.stats as sts D_theoretical = integrate.quad(lambda x: 1.5 * (x ** 4), -1, 1)[0] - \ (integrate.quad(lambda x: 1.5 * (x ** 3), -1, 1))[0] print("D (theoretical) = ", D_theoretical) gamma = [0.9, 0.95, 0.99] N = [20, 30, 50, 70, 100, 150] all_intervals = list() for ni in N: intervals = [] intervals2 = [] T = [] Y = get_Y(ni) print("Вариационный ряд: ") print(Y) My = sum(Y) / ni print('My = ', My) Dy = 0 for y in Y: Dy += (y - My)**2 Dy = Dy / (ni - 1) print('Dy = ', Dy) t_rv = sts.t(ni - 1) arr = t_rv.rvs(1000000) for i in gamma:
import matplotlib.pyplot as plt import numpy as np import math from creature_Y import get_Y, empiric_func n = 30 Y = get_Y(n) print("Вариационный ряд: ") print(Y) fig, ax = plt.subplots(1, 1, figsize=(16, 9)) y = empiric_func(Y) plt.step(Y, y, color='r', label='Эмпирическая функция распределения') plt.plot([-1.5, Y[0]], [0, 0], color='r') plt.plot([Y[-1], 1.5], [1, 1], color='r') plt.plot([Y[0], Y[0]], [0, y[1]], color='r') y_theoretical = list() for yi in Y: y_theoretical.append((yi**3 + 1) / 2) x_theoretical = np.linspace(-1, 1, 1000) plt.plot(x_theoretical, (x_theoretical**3 + 1) / 2, color='blue', label='Теоретическая функция распределения') plt.legend() d_plus = [] d_minus = [] for i in range(0, n): d_plus.append((i / n) - ((Y[i])**3 + 1) / 2) d_minus.append((((Y[i])**3 + 1) / 2) - ((i - 1) / n))