Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- import scipy.stats as stats
- import matplotlib.pyplot as plt
- from IPython.display import Latex
- data = [3.31, 1.15, 2.44, 0.82, 1.50, 2.53, 2.18, 3.20,
- 2.85, 2.27, 1.97, 0.98, 3.51, 2.42, 2.09, 2.83,
- 2.76, 0.18, 1.61, 2.21, 2.33, 3.06, 1.70, 2.44,
- 1.82, 3.02, 3.63, 1.52, 2.01, 2.17, 2.63, 1.94,
- 2.49, 2.31, 2.37, 1.03, 2.06, 0.67, 2.79, 2.42,
- 2.95, 0.45, 1.20, 1.61, 2.35, 1.73, 0.82, 1.10,
- 1.94, 2.14, 2.28, 2.54, 1.85, 2.40, 1.94, 1.30,
- 1.62, 2.03, 2.00, 2.70, 2.33, 2.86, 3.26, 1.71,
- 2.70, 2.96, 2.89, 0.73, 1.01, 1.85, 2.79, 3.10,
- 2.42, 3.12, 2.43, 1.85, 1.21, 1.53, 2.95, 1.22]
- desc_stats = pd.DataFrame(columns=['Valid N', 'Mean', 'Min', 'Max', 'Std.Dev.', 'Skewness', 'Kurtosis'], index=['Value'])
- desc_stats.loc['Value'] = [len(data), np.mean(data), min(data), max(data), np.std(data), stats.skew(data), stats.kurtosis(data)]
- print(desc_stats)
- counts, bin_edges, _ = plt.hist(data, bins=10, edgecolor='black')
- plt.xticks(ticks=bin_edges, rotation=45, ha='right')
- plt.title('Гістограма')
- plt.xlabel('Інтервали')
- plt.ylabel('Частота')
- plt.show()
- # Розрахунок ймовірності для інтервалу P(1.22 < X < 1.84)
- mean = np.mean(data)
- std_dev = np.std(data)
- # Функція нормального розподілу
- prob_1_22 = stats.norm.cdf(1.84, mean, std_dev) - stats.norm.cdf(1.22, mean, std_dev)
- display(Latex(f"Ймовірність $P(1.22 < X < 1.84): {round(prob_1_22*100, 2)}$%"))
- lower_bound = mean*0.9
- upper_bound = mean*1.1
- prob_lower = stats.norm.cdf(lower_bound, mean, std_dev)
- prob_upper = stats.norm.cdf(upper_bound, mean, std_dev)
- probability = prob_upper - prob_lower
- percentage = probability * 100
- display(Latex(f"Випуск придатної продукції: ${round(percentage, 2)}$%"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement