{"id":368817,"date":"2024-05-21T03:50:11","date_gmt":"2024-05-21T03:50:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=368817"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=368817","title":{"rendered":"<span>\u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430. \u0427\u0430\u0441\u0442\u044c 2. \u0410 \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0440\u0435\u043d\u0434?<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/787098\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 Habr \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u043e\u0446\u0435\u043d\u043a\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0435\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438. \u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/781060\/\" rel=\"noopener noreferrer nofollow\">A\/B \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438<\/a>, \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0435\u043d\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u0430\u044f \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0433\u043e\u0434\u0430 \u0432 \u0433\u043e\u0434, \u043e\u0446\u0435\u043d\u043a\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u0430 \u0434\u0432\u0430 \u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430, \u0438 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c.<\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d \u2014 \u0442\u0440\u0435\u043d\u0434 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438 \u0447\u0430\u0441\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u043e\u0441\u0442 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u043b\u0430\u0433\u043e\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u044f, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u0438\u043b\u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<h2>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437<\/h2>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0438\u0433\u0440\u0430\u0435\u0442 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u043d\u0434\u0430, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u0421\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f, \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043b\u0438\u0448\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0438 \u0442\u0440\u0435\u043d\u0434\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u041e\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u0442\u0438\u043f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0438 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns   def generate_data(     n_samples: int,     loc: int = 100,     scale: int = 3,     trend_max: int = 20,     hetero: float = 1,     n_outliers: int = 0, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     metric_values = (         loc         + np.random.normal(scale=scale, size=n_samples)         * np.linspace(1, hetero, n_samples)         + np.linspace(0, trend_max, n_samples)     )      for i in range(n_outliers):         metric_values[i * n_samples \/\/ n_outliers] = np.max(metric_values) * 1.02      return pd.DataFrame({\"time\": time, \"metric\": metric_values})   def rolling_data(data, window_size=10):     return data.rolling(window=window_size).mean()   ONE_MONTH = 24 * 30 test_data_1 = generate_data(ONE_MONTH, hetero=1, trend_max=20, scale=3) test_data_2 = generate_data(ONE_MONTH, hetero=1, trend_max=20, scale=10) smoothed_data = rolling_data(test_data_2[\"metric\"])  fig, axes = plt.subplots(3, 1, figsize=(10, 12))  sns.lineplot(x=\"time\", y=\"metric\", data=test_data_1, ax=axes[0], alpha=0.5) axes[0].set_ylim(0, 200) axes[0].set_title(\"Low variance\")  sns.lineplot(x=\"time\", y=\"metric\", data=test_data_2, ax=axes[1], alpha=0.5) axes[1].set_ylim(0, 200) axes[1].set_title(\"High variance\")  axes[2].plot(test_data_2[\"time\"], smoothed_data, alpha=0.5, color=\"red\") axes[2].set_ylim(0, 200) axes[2].set_title(\"High variance and rolling window\")  plt.subplots_adjust(hspace=0.5) plt.show() <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e1f\/cb5\/bc7\/e1fcb5bc7941faaa076382c7dc108da7.png\" width=\"2026\" height=\"534\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e1f\/cb5\/bc7\/e1fcb5bc7941faaa076382c7dc108da7.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6f7\/7f5\/67a\/6f77f567af768b23dccfad9fcecf9c89.png\" width=\"2034\" height=\"534\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6f7\/7f5\/67a\/6f77f567af768b23dccfad9fcecf9c89.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e5b\/b5a\/f12\/e5bb5af12ab1a017e50c527ed9ed6b24.png\" width=\"1992\" height=\"516\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e5b\/b5a\/f12\/e5bb5af12ab1a017e50c527ed9ed6b24.png\"\/><\/figure>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0438\u0437\u043a\u0430\u044f, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043c\u0435\u043d\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0431\u043e\u043b\u0435\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0448\u0443\u043c\u043d\u044b\u0435, \u043a\u0430\u043a \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u043c. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0448\u0443\u043c\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0438\u043b\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435. \u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0438 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0438\u0439 \u0442\u0440\u0435\u043d\u0434 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u043d\u0438\u0437\u0438\u0442 \u0435\u0433\u043e \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a \u043d\u043e\u0432\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u043e.<\/p>\n<h2>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/h2>\n<p>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u0442\u0440\u0435\u043d\u0434\u0430. \u041e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0442\u044a\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e <a href=\"https:\/\/ocw.mit.edu\/courses\/18-655-mathematical-statistics-spring-2016\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0443\u0440\u0441\u043e\u0432<\/a> \u043f\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u0438 <a href=\"https:\/\/grow.google\/certificates\/data-analytics\/\" rel=\"noopener noreferrer nofollow\">\u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/a>.<\/p>\n<p>\u041e\u0434\u043d\u043e \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c, \u043c\u0430\u043b\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044f\u0445.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u043b\u044e\u0441 \u0432 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u043c\u0438\u043d\u0443\u0441\u043e\u043c &#8212; \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0433\u0438\u0431\u043a\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u043d\u0434 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0435\u0432\u0435\u0440\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<p>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c). \u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u0430\u043c.<\/p>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u0430\u043c<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438.<\/strong> <\/p>\n<ul>\n<li>\n<p>\u0413\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/studfile.net\/preview\/2069367\/page:20\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442<\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Breusch-Pagan test.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c <\/strong>R\u00b2<strong> \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0443\u0433\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430.<\/strong> <\/p>\n<ul>\n<li>\n<p>R\u00b2 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0438. \u0427\u0435\u043c \u043e\u043d \u0431\u043b\u0438\u0436\u0435 \u043a 1, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b-\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u044e. \u041d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0438\u0437\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f R\u00b2 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u044e\u0442 \u043e \u043d\u0435\u0441\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u0448\u0443\u043c\u043d\u044b\u0435 \u0438 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u044b, R\u00b2 \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u0438\u043c, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438\u043b\u0438 \u044f\u0432\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430. \u0414\u0435\u0442\u0430\u043b\u044c\u043d\u0435\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0438\u0436\u0435.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a<\/strong> <\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0432\u0430\u0436\u043d\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u043e\u0446\u0435\u043d\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430, \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u043a \u0442\u0435\u0441\u0442 \u0414\u0430\u0440\u0431\u0438\u043d\u0430-\u0423\u043e\u0442\u0441\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0432 \u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439 \u0441 \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/articles\/693402\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u0431\u044b\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0414\u0430\u0440\u0431\u0438\u043d\u0430-\u0423\u043e\u0442\u0441\u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 1.5 \u0434\u043e 2.5, \u044d\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0414\u0430\u0440\u0431\u0438\u043d\u0430-\u0423\u043e\u0442\u0441\u043e\u043d\u0430 \u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442 p-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430.<\/strong> <\/p>\n<ul>\n<li>\n<p>\u041e \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0417\u0434\u0435\u0441\u044c \u043b\u0438\u0448\u044c \u0443\u0442\u043e\u0447\u043d\u0438\u043c \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0448\u0438\u0440\u043e\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c. \u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 1000 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0443\u0442\u0441\u0440\u0430\u043f\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0433\u043e\u043b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0430\u043b\u0435\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0434\u0430 \u043d\u0430 Python \u0438 Scipy , \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.<\/p>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c  \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt  import numpy as np  import pandas as pd import scipy.stats as stats  import seaborn as sns import statsmodels.api as sm   def generate_data(     n_samples: int,     loc: int = 100,     scale: int = 10,     trend_max: int = 10,     hetero: float = 2, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")      metric_values = (         loc         + np.random.normal(scale=scale, size=n_samples)         * np.linspace(1, hetero, n_samples)         + np.linspace(0, trend_max, n_samples)     )      return pd.DataFrame({\"time\": time, \"metric\": metric_values})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH)  # plot data  sns.lineplot(x=\"time\", y=\"metric\", data=test_data, alpha=0.5) # fit linear regression slope, intercept, rvalue, pvalue, stderr = stats.linregress(     test_data.index, test_data.metric )  # test for Homoscedasticity of the residuals   def test_homoscedasticity(test_data: pd.DataFrame):     # prepare y and X for statsmodels     y = test_data.metric     X_sm = test_data.index     X_sm = sm.add_constant(X_sm)     # fit linear regression using statsmodels     mod_sm = sm.OLS(y, X_sm)     res_sm = mod_sm.fit()     # test for Homoscedasticity     bp_lm, bp_lm_pvalue, bp_fvalue, bp_f_pvalue = sm.stats.diagnostic.het_breuschpagan(         res_sm.resid, res_sm.model.exog     )      return bp_f_pvalue   bp_f_pvalue = test_homoscedasticity(test_data) if bp_f_pvalue &lt; 0.05:     print(\"Residuals are not Homoscedastic. Linear regression may be invalid\") else:     print(\"Residuals are Homoscedastic\")   # test autocorrelation def test_autocorrelation(residuals):     dw_statistic = sm.stats.durbin_watson(residuals)     return dw_statistic   # Assuming you have the 'residuals' variable defined elsewhere in your code # Conduct the test for autocorrelation   # Check the p-value and print the result residuals = test_data.metric - (intercept + slope * test_data.index) dw_statistic = test_autocorrelation(residuals)  if dw_statistic > 1.5 and 2.5:     print(\"Errors are independent (no signs of autocorrelation)\") else:     print(         \"\u0410utocorrelation in the residuals. Independence of errors is not satisfactory.\"     )  # bootstrap linear regression slope n_iterations = 1000 slopes = np.zeros(n_iterations) intercepts = np.zeros(n_iterations) r_square = np.zeros(n_iterations) for i in range(n_iterations):     sample = test_data.sample(frac=1, replace=True)     slope, intercept, rvalue, pvalue, stderr = stats.linregress(         sample.index, sample.metric     )     slopes[i] = slope     intercepts[i] = intercept     r_square[i] = rvalue**2 # calculate 95% confidence interval slopes_quantiles = np.percentile(slopes, [2.5, 97.5]) intercept_quantiles = np.percentile(intercepts, [2.5, 97.5]) r_square_quantiles = np.percentile(r_square, [2.5, 97.5]) print(f\"r_square is between {r_square_quantiles}\") print(f\"slope is between {slopes_quantiles}\")   # plot two lines for the confidence interval slopes plt.plot(     test_data.time,     intercept_quantiles[0] + slopes_quantiles[0] * test_data.index,     label=\"lower bound\",     color=\"green\",     linestyle=\"--\",     linewidth=2, )  plt.plot(     test_data.time,     intercept_quantiles[1] + slopes_quantiles[1] * test_data.index,     label=\"upper bound\",     color=\"green\",     linestyle=\"--\",     linewidth=2, )  # plot linear regression  plt.plot(     test_data.time,     intercept + slope * test_data.index,     label=\"fitted line\",     color=\"red\",     linewidth=2, )  plt.legend() plt.show()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/01f\/ee7\/43a\/01fee743a2e3053491c069db097ce3cd.png\" alt=\"\" title=\"\" width=\"1096\" height=\"476\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/01f\/ee7\/43a\/01fee743a2e3053491c069db097ce3cd.png\"\/><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0441 \u0443\u0433\u043b\u043e\u043c \u043d\u0430\u043a\u043b\u043e\u043d\u0430 (slope) \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 \u043e\u0442 ~0.012 \u0434\u043e 0.018. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0435\u043d\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442 0.012 \u0434\u043e 0.018 \u0435\u0434\u0438\u043d\u0438\u0446. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438, \u0430 \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bde\/c5a\/b0a\/bdec5ab0a85417811048cc0da0fbdb8f.png\" width=\"609\" height=\"50\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bde\/c5a\/b0a\/bdec5ab0a85417811048cc0da0fbdb8f.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0434\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0438 \u0435\u0433\u043e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0435, \u0447\u0442\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c. <\/h3>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0433\u0435\u0442\u0435\u0440\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043f\u0440\u0438 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt import numpy as np import pandas as pd import scipy.stats as stats import seaborn as sns import statsmodels.api as sm   def generate_data(     n_samples: int,     loc: int = 100,     scale: int = 10,     trend_max: int = 10,     hetero: float = 30, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")      metric_values = (         loc         + np.random.normal(scale=scale, size=n_samples)         * np.linspace(1, hetero, n_samples)         + np.linspace(0, trend_max, n_samples)     )      return pd.DataFrame({\"time\": time, \"metric\": metric_values})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH)  # plot data  sns.lineplot(x=\"time\", y=\"metric\", data=test_data, alpha=0.5) # fit linear regression slope, intercept, rvalue, pvalue, stderr = stats.linregress(     test_data.index, test_data.metric )  # test for Homoscedasticity of the residuals   def test_homoscedasticity(test_data: pd.DataFrame):     # prepare y and X for statsmodels     y = test_data.metric     X_sm = test_data.index     X_sm = sm.add_constant(X_sm)     # fit linear regression using statsmodels     mod_sm = sm.OLS(y, X_sm)     res_sm = mod_sm.fit()     # test for Homoscedasticity     bp_lm, bp_lm_pvalue, bp_fvalue, bp_f_pvalue = sm.stats.diagnostic.het_breuschpagan(         res_sm.resid, res_sm.model.exog     )      return bp_f_pvalue   bp_f_pvalue = test_homoscedasticity(test_data) if bp_f_pvalue &lt; 0.05:     print(\"Residuals are not Homoscedastic. Linear regression may be invalid\") else:     print(\"Residuals are Homoscedastic\")   # test autocorrelation def test_autocorrelation(residuals):     dw_statistic = sm.stats.durbin_watson(residuals)     return dw_statistic   # Assuming you have the 'residuals' variable defined elsewhere in your code # Conduct the test for autocorrelation   # Check the p-value and print the result residuals = test_data.metric - (intercept + slope * test_data.index) dw_statistic = test_autocorrelation(residuals)  if dw_statistic > 1.5 and 2.5:     print(\"Errors are independent (no signs of autocorrelation)\") else:     print(         \"\u0410utocorrelation in the residuals. Independence of errors is not satisfactory.\"     )  # bootstrap linear regression slope n_iterations = 1000 slopes = np.zeros(n_iterations) intercepts = np.zeros(n_iterations) r_square = np.zeros(n_iterations)  for i in range(n_iterations):     sample = test_data.sample(frac=1, replace=True)     slope, intercept, rvalue, pvalue, stderr = stats.linregress(         sample.index, sample.metric     )     slopes[i] = slope     intercepts[i] = intercept     r_square[i] = rvalue**2 # calculate 95% confidence interval slopes_quantiles = np.percentile(slopes, [2.5, 97.5]) intercept_quantiles = np.percentile(intercepts, [2.5, 97.5]) r_square_quantiles = np.percentile(r_square, [2.5, 97.5]) print(f\"r_square is between {r_square_quantiles}\") print(f\"slope is between {slopes_quantiles}\")   # plot two lines for the confidence interval slopes plt.plot(     test_data.time,     intercept_quantiles[0] + slopes_quantiles[0] * test_data.index,     label=\"lower bound\",     color=\"green\",     linestyle=\"--\",     linewidth=2, )  plt.plot(     test_data.time,     intercept_quantiles[1] + slopes_quantiles[1] * test_data.index,     label=\"upper bound\",     color=\"green\",     linestyle=\"--\",     linewidth=2, )   # plot linear regression  plt.plot(     test_data.time,     intercept + slope * test_data.index,     label=\"fitted line\",     color=\"red\",     linewidth=2, )  plt.legend() plt.show()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u0441\u0442 Breusch-Pagan<strong> <\/strong>\u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0440\u0438\u0437\u0443\u0435\u0442 \u043e \u0442\u043e\u043c \u0447\u0442\u043e<strong> <\/strong>\u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u043e\u0448\u0438\u0431\u043e\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1f5\/0f7\/891\/1f50f7891066fa7abb708b6ff91ea5c6.png\" width=\"651\" height=\"32\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1f5\/0f7\/891\/1f50f7891066fa7abb708b6ff91ea5c6.png\"\/><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/17c\/65b\/3bd\/17c65b3bd359e7de33966736d539b800.png\" width=\"1058\" height=\"614\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/17c\/65b\/3bd\/17c65b3bd359e7de33966736d539b800.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/723\/16a\/63d\/72316a63dc22cd157c7cb93819223100.png\" width=\"1052\" height=\"540\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/723\/16a\/63d\/72316a63dc22cd157c7cb93819223100.png\"\/><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c\u0438, \u0438 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u0442\u0430\u043a \u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0435\u043d\u0434. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u0432\u043e\u0434\u044b \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0442\u0440\u0435\u043d\u0434\u0430 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432. \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f \u0441 \u0433\u0435\u0442\u0435\u0440\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c\u044e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/books.econ.msu.ru\/Introduction-to-Econometrics\/chap05\/5.3\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>, \u043e\u0434\u043d\u0430\u043a\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u043c, \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044f\u0432\u043d\u043e\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h3>\u041e\u0446\u0435\u043d\u043a\u0430 R\u00b2<\/h3>\n<p>\u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0433 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d\u0430 \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0430\u0446\u0438\u0438 R\u00b2. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u044d\u0442\u043e\u043c\u0443, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442, \u0447\u0442\u043e R\u00b2 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u043c\u0435\u0436\u0434\u0443 0.06 \u0438 0.14. \u042d\u0442\u043e \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u0430\u0431\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e, \u0432 \u0446\u0435\u043b\u043e\u043c, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 \u043d\u0430\u0448\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u0430 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0432\u044b\u0441\u043e\u043a\u0438\u043c \u0443\u0440\u043e\u0432\u043d\u0435\u043c \u0448\u0443\u043c\u0430.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0445, \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0438\u0437\u043a\u0438\u0439 R\u00b2 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e \u043f\u043b\u043e\u0445\u043e\u043c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt  import numpy as np  import pandas as pd import scipy.stats as stats  import seaborn as sns import statsmodels.api as sm   def generate_data(         n_samples: int,         loc: int = 100,         scale: int = 30,         trend_max: int = 100,         hetero: float = 1 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")      metric_values = (             loc             + np.random.normal(scale=scale, size=n_samples)             * np.linspace(1, hetero, n_samples)             + np.linspace(0, trend_max, n_samples)     )      return pd.DataFrame({\"time\": time, \"metric\": metric_values})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH)  # plot data  sns.lineplot(x=\"time\", y=\"metric\", data=test_data, alpha=0.5) # fit linear regression slope, intercept, rvalue, pvalue, stderr = stats.linregress(     test_data.index, test_data.metric )   # test for Homoscedasticity of the residuals  def test_homoscedasticity(test_data: pd.DataFrame):     # prepare y and X for statsmodels     y = test_data.metric     X_sm = test_data.index     X_sm = sm.add_constant(X_sm)     # fit linear regression using statsmodels     mod_sm = sm.OLS(y, X_sm)     res_sm = mod_sm.fit()     # test for Homoscedasticity     bp_lm, bp_lm_pvalue, bp_fvalue, bp_f_pvalue = sm.stats.diagnostic.het_breuschpagan(         res_sm.resid, res_sm.model.exog     )      return bp_f_pvalue   bp_f_pvalue = test_homoscedasticity(test_data) if bp_f_pvalue &lt; 0.05:     print(\"Residuals are not Homoscedastic. Linear regression may be invalid\") else:     print(\"Residuals are Homoscedastic\")   # test autocorrelation def test_autocorrelation(residuals):     dw_statistic = sm.stats.durbin_watson(residuals)     return dw_statistic   # Assuming you have the 'residuals' variable defined elsewhere in your code # Conduct the test for autocorrelation   # Check the p-value and print the result residuals = test_data.metric - (intercept + slope * test_data.index) dw_statistic = test_autocorrelation(residuals)  if dw_statistic > 1.5 and 2.5:     print(\"Errors are independent (no signs of autocorrelation)\") else:     print(\"\u0410utocorrelation in the residuals. Independence of errors is not satisfactory.\")  # bootstrap linear regression slope n_iterations = 1000 slopes = np.zeros(n_iterations) intercepts = np.zeros(n_iterations) r_square = np.zeros(n_iterations) for i in range(n_iterations):     sample = test_data.sample(frac=1, replace=True)     slope, intercept, rvalue, pvalue, stderr = stats.linregress(         sample.index, sample.metric     )     slopes[i] = slope     intercepts[i] = intercept     r_square[i] = rvalue ** 2 # calculate 95% confidence interval slopes_quantiles = np.percentile(slopes, [2.5, 97.5]) intercept_quantiles = np.percentile(intercepts, [2.5, 97.5]) r_square_quantiles = np.percentile(r_square, [2.5, 97.5]) print(f'r_square is between {r_square_quantiles}') print(f'slope is between {slopes_quantiles}')  # plot two lines for the confidence interval slopes plt.plot(     test_data.time,     intercept_quantiles[0] + slopes_quantiles[0] * test_data.index,     label=\"lower bound\",     color=\"green\",     linestyle='--',     linewidth=2 )  plt.plot(     test_data.time,     intercept_quantiles[1] + slopes_quantiles[1] * test_data.index,     label=\"upper bound\",     color=\"green\",     linestyle='--',     linewidth=2 )  # plot linear regression  plt.plot(     test_data.time,     intercept + slope * test_data.index,     label=\"fitted line\",     color=\"red\",     linewidth=2 )  plt.legend() plt.show()<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6cd\/535\/9d3\/6cd5359d39ed45500161276f7f620c2f.png\" width=\"1063\" height=\"505\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6cd\/535\/9d3\/6cd5359d39ed45500161276f7f620c2f.png\"\/><\/figure>\n<p>\u0417\u0430 \u043f\u0435\u0440\u0438\u043e\u0434 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0440\u043e\u0441\u043b\u043e \u0432 2 \u0440\u0430\u0437\u0430 trend_max = 100, \u043d\u043e \u0438\u0437 \u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b-\u0432\u0430 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432 \u0438 \u0448\u0443\u043c\u0430 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 R\u00b2 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u0438\u0439. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0447\u0442\u043e R\u00b2, \u0432\u043e\u043f\u0440\u0435\u043a\u0438 \u0440\u0430\u0441\u0445\u043e\u0436\u0438\u043c \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u044f\u043c \u043d\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0430 \u043b\u0438\u0448\u044c \u043e \u0442\u043e\u043c \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0430 \u0442\u043e\u0447\u043d\u043e \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0448\u0443 \u0444\u0443\u043a\u043d\u0446\u0438\u044e, \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0438\u0437\u043a\u0438\u0439. \u0412\u0430\u0436\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0435\u0441\u0442\u044b \u0438 \u043d\u0430 slope.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/221\/beb\/d4f\/221bebd4f7bd5f6a2d15f5d70121dfd2.png\" width=\"467\" height=\"76\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/221\/beb\/d4f\/221bebd4f7bd5f6a2d15f5d70121dfd2.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u043d\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b\u0438 \u0432\u0430\u0436\u043d\u0443\u044e \u0441\u043b\u0430\u0431\u043e\u0441\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 &#8212; \u0435\u0435 \u043d\u0435\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c \u043a \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c. \u042d\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0448\u0438\u0440\u043e\u043a\u0438\u0445 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u0445 \u0434\u043b\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043d\u0430\u043a\u043b\u043e\u043d\u0430. \u0414\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0447\u0430\u0441\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b\u0445 \u043b\u0443\u0447\u0448\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0434\u0430\u043b\u0435\u0435.<\/p>\n<h2>Mann-Kendall test<\/h2>\n<p>\u041c\u0435\u0442\u043e\u0434 \u041c\u0430\u043d\u043d-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043d\u0435\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u043d\u0430 \u0440\u0430\u043d\u0433\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0430 \u043b\u0438\u0448\u044c \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u0437\u043d\u0430\u043a \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>\u0421\u0440\u0435\u0434\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0430\u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443\u0436\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0440\u0435\u043d\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u043d \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u0430\u043c \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438, \u0433\u0434\u0435 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c\u0438.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import scipy.stats as stats   def generate_data(         n_samples: int,         loc: int = 100,         scale: int = 0.1,         trend_max: int = 0.5,         hetero: float = 1,         outlier: bool = False, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     metric_values = (             loc             + np.random.normal(scale=scale, size=n_samples)             * np.linspace(1, hetero, n_samples)             + np.linspace(0, trend_max, n_samples)     )     if outlier:         metric_values[n_samples \/\/ 2] = -np.max(metric_values) * 1000     return pd.DataFrame({\"time\": time, \"metric\": metric_values})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH) # test mann-kendall trend n_iterations = 100 p_values = np.zeros(n_iterations) taus = np.zeros(n_iterations) for i in range(n_iterations):     test_data = generate_data(ONE_MONTH)     tau, pvalue = stats.mstats.kendalltau(test_data.index, test_data.metric)     taus[i] = np.round(tau, 2)     p_values[i] = pvalue  tau_quantiles = np.percentile(taus, [2.5, 97.5]) # number of times we reject the null hypothesis print(f'trend is significant in {np.sum(p_values &lt; 0.05)} cases from {n_iterations}') print(f'tau_quantiles interval {tau_quantiles}')<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/038\/45d\/328\/03845d328a33c5351fd6a305631ee137.png\" width=\"508\" height=\"27\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/038\/45d\/328\/03845d328a33c5351fd6a305631ee137.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0442\u0435\u0441\u0442 \u041c\u0430\u043d\u043d\u0430-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430, \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0439 \u043a \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0432 100 \u0438\u0437 100 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0442\u0440\u0435\u043d\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u0430\u0436\u0435 \u0431\u0443\u0441\u0442\u0440\u0430\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u041c\u0430\u043d\u043d\u0430-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430. \u041f\u043e\u043c\u0438\u043c\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f p-value, \u0442\u0435\u0441\u0442 \u041c\u0430\u043d\u043d\u0430-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 tau, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 -1 \u0434\u043e 1. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0441\u0442\u044c, -1 \u043d\u0430 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e, \u0430 0 \u043d\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0441\u0442\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0441\u043b\u043e\u0436\u043d\u0430 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0435 \u0442\u0440\u0435\u043d\u0434\u0430. \u0412 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 tau \u043e\u043a\u043e\u043b\u043e 0.6, \u0447\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u043d\u0435 \u0434\u0430\u0451\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0435 \u0442\u0440\u0435\u043d\u0434\u0430.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ed1\/33a\/e03\/ed133ae033d3e8ea90bd9f2f3f7ee95e.png\" width=\"371\" height=\"28\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ed1\/33a\/e03\/ed133ae033d3e8ea90bd9f2f3f7ee95e.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0442\u0440\u0435\u043d\u0434\u0430 \u0432 \u0442\u0435\u0441\u0442\u0435 \u041c\u0430\u043d-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0446\u0435\u043d\u043a\u0443 \u0443\u0433\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043d\u0430 \u0442\u0435\u0445 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0447\u0442\u043e slope \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4db\/92a\/c17\/4db92ac17dc27cf18fdba8b08bbcbb04.png\" width=\"409\" height=\"31\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4db\/92a\/c17\/4db92ac17dc27cf18fdba8b08bbcbb04.png\"\/><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0443\u0433\u043e\u043b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0448\u0430\u0433\u0435, \u0442\u043e \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u043c\u044b\u0441\u043b \u0432 \u0441\u0430\u043c\u043e\u043c \u0442\u0435\u0441\u0442\u0435 \u041c\u0430\u043d-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0447\u0430\u0441\u0442\u044b\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 \u043d\u0430 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0440\u0435\u043d\u0434\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u0430\u043c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430, \u0447\u0442\u043e \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043e \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445. <\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u043a \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430\u043c \u0442\u0435\u0441\u0442\u0430 \u041c\u0430\u043d\u043d\u0430-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043d\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0442\u0440\u0435\u043d\u0434\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445. <\/p>\n<h2>Spearman\u2019s Rank Correlation Test<\/h2>\n<p>\u0422\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0442\u0435\u0441\u0442 \u041c\u0430\u043d\u043d-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430, \u0442\u0435\u0441\u0442 \u0421\u043f\u0438\u0440\u043c\u0435\u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0440\u0430\u043d\u0433\u043e\u0432. \u0412 \u0442\u0435\u0441\u0442\u0435 \u0421\u043f\u0438\u0440\u043c\u0435\u043d\u0430 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0421\u043f\u0438\u0440\u043c\u0435\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043c\u043e\u043d\u043e\u0442\u043e\u043d\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import scipy.stats as stats   def generate_data(         n_samples: int,         loc: int = 100,         scale: int = 0.1,         trend_max: int = 0.1,         hetero: float = 1,         num_outliers: int = 50, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     metric_values = (             loc             + np.random.normal(scale=scale, size=n_samples)             * np.linspace(1, hetero, n_samples)             + np.linspace(0, trend_max, n_samples)     )     if num_outliers > 0:         indices_outliers = np.random.choice(n_samples, num_outliers, replace=False)         metric_values[indices_outliers] = np.max(metric_values) * 100      return pd.DataFrame({\"time\": time, \"metric\": metric_values})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH)  # test mann-kendall trend n_iterations = 100  p_values_mk = np.zeros(n_iterations) taus = np.zeros(n_iterations)  p_values_sp = np.zeros(n_iterations) spearman_coefficients = np.zeros(n_iterations)  for i in range(n_iterations):     test_data = generate_data(ONE_MONTH)     tau, p_value_mk = stats.mstats.kendalltau(test_data.index, test_data.metric)     spearman_coefficient, p_value_sp = stats.spearmanr(test_data.index, test_data.metric)     taus[i] = np.round(tau, 2)     p_values_mk[i] = p_value_mk      spearman_coefficients[i] = round(spearman_coefficient, 2)     p_values_sp[i] = p_value_sp  tau_quantiles = np.percentile(taus, [2.5, 97.5]) spearman_quantiles = np.percentile(spearman_coefficients, [2.5, 97.5]) # number of times we reject the null hypothesis  print(f'MK trend is significant in {np.sum(p_values_mk &lt; 0.05)} cases from {n_iterations}') print(f'SP trend is significant in {np.sum(p_values_sp &lt; 0.05)} cases from {n_iterations}')  print(f'tau_quantiles interval {tau_quantiles}') print(f'spearman_quantiles interval {spearman_quantiles}')<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/629\/eba\/9c5\/629eba9c581d9a9fa1af7547896833e2.png\" width=\"472\" height=\"124\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/629\/eba\/9c5\/629eba9c581d9a9fa1af7547896833e2.png\"\/><\/figure>\n<p>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0430 \u041c\u0430\u043d-\u041a\u0435\u043d\u0434\u0430\u043b\u043b\u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0438 \u043d\u0430 \u0442\u0435\u0441\u0442 \u0421\u043f\u0438\u0440\u043c\u0430\u043d\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a \u043d\u0438\u0437\u043a\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0443\u0433\u043b\u043e\u0432 \u0442\u0440\u0435\u043d\u0434\u0430, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0430\u0432\u0438\u0442 \u043f\u043e\u0434 \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445 \u0433\u0434\u0435 \u0446\u0435\u043b\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0438 \u043f\u043e\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440.<\/p>\n<h2>Repeated median regression (RMR)<\/h2>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u043a \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c \u043f\u0440\u0438\u0432\u0435\u043b\u0430 \u043a \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e \u0446\u0435\u043b\u043e\u0433\u043e \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0440\u043e\u0431\u0430\u0441\u0442\u043d\u044b\u0445 \u043a \u0440\u0435\u0434\u043a\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c. \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430: \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u043b\u0438\u043d\u0438\u0438, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0430\u044f \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0451 \u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438, \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f  \u0443\u0433\u043e\u043b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u044d\u0442\u043e\u0439 \u043b\u0438\u043d\u0438\u0438. \u0417\u0430\u0442\u0435\u043c \u0438\u0437 \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0443\u0433\u043b\u043e\u0432 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0434\u0438\u0430\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u0438 \u0437\u0430\u0442\u0435\u043c \u0441\u043d\u043e\u0432\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0435\u0434\u0438\u0430\u043d\u0430 \u0432\u0441\u0435\u0445 \u043c\u0435\u0434\u0438\u0430\u043d.<\/p>\n<p><strong>\u041a\u043e\u0433\u0434\u0430 \u043e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u0421 \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445:<\/strong> \u041c\u0435\u0442\u043e\u0434 \u0440\u043e\u0431\u0430\u0441\u0442\u0435\u043d \u043a \u043d\u0430\u043b\u0438\u0447\u0438\u044e \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432 \u0438 \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u0439, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0432 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445, \u0433\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u0437-\u0437\u0430 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/strong> \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u043f\u0440\u0438 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0430\u0446\u0438\u0438 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438:<\/strong> \u041c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0438 \u0448\u0443\u043c \u0438\u043b\u0438 \u043d\u0435\u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442 \u0443\u0433\u043b\u044b \u043d\u0430\u043a\u043b\u043e\u043d\u0430, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e,  \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt import numpy as np import pandas as pd import scipy.stats as stats import seaborn as sns import statsmodels.api as sm   def generate_data(     n_samples: int,     loc: int = 100,     scale: int = 10,     trend_max: int = 20,     hetero: float = 10,     n_outliers: int = 30, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     metric_values = (         loc         + np.random.normal(scale=scale, size=n_samples)         * np.linspace(1, hetero, n_samples)         + np.linspace(0, trend_max, n_samples)     )      for i in range(n_outliers):         metric_values[i * n_samples \/\/ n_outliers] = -np.max(metric_values) * 10     return pd.DataFrame({\"time\": time, \"metric\": metric_values})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH)   # bootstrap linear regression slope n_iterations = 100 slopes_RMR = np.zeros(n_iterations) intercepts_RMR = np.zeros(n_iterations) slopes_LR = np.zeros(n_iterations) intercepts_LR = np.zeros(n_iterations) for i in range(n_iterations):     sample = test_data.sample(frac=1, replace=True)     res = stats.siegelslopes(sample.metric, sample.index)     slopes_RMR[i] = res.slope     intercepts_RMR[i] = res.intercept     res_reg = stats.linregress(sample.metric, sample.index)     slopes_LR[i] = res_reg.slope     intercepts_LR[i] = res_reg.intercept # calculate 95% confidence interval slopes_quantiles_RMR = np.percentile(slopes_RMR, [2.5, 97.5]) intercept_quantiles_RMR = np.percentile(intercepts_RMR, [2.5, 97.5])  slopes_quantiles_LR = np.percentile(slopes_LR, [2.5, 97.5]) intercept_quantiles_LR = np.percentile(intercepts_LR, [2.5, 97.5])  # results RMR and LR print(f\"RMR  95% confidence interval for slope: {slopes_quantiles_RMR}\") print(f\"RMR  95% confidence interval for intercept: {intercept_quantiles_RMR}\")  print(f\"LR 95% confidence interval for slope: {slopes_quantiles_LR}\") print(f\"LR 95% confidence interval for intercept: {intercept_quantiles_LR}\")<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3e6\/5d8\/6e9\/3e65d86e9794c113ab3d10461c18ea8d.png\" width=\"721\" height=\"115\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3e6\/5d8\/6e9\/3e65d86e9794c113ab3d10461c18ea8d.png\"\/><\/figure>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432, \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432 \u043a \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c, \u043d\u043e \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u043e\u043c. \u0414\u0440\u0443\u0433\u0438\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043c\u0435\u043d\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u043a \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044f\u043c \u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0432\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0443\u0440\u043e\u0432\u043d\u044f\u0445 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u043c\u0435\u043d\u0435\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d, \u0438 \u043f\u0440\u0438 \u0432\u044b\u0441\u043e\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u0438 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0442\u0430\u043a\u0436\u0435 \u0443\u0445\u0443\u0434\u0448\u0430\u0435\u0442\u0441\u044f. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438 hetero=30.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ed\/9ba\/0fa\/5ed9ba0fab1f603122f7012bd4028a7c.png\" width=\"738\" height=\"136\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ed\/9ba\/0fa\/5ed9ba0fab1f603122f7012bd4028a7c.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e RMR \u0432\u044b\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u044b\u0435 \u043a \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0443 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043a\u0440\u0430\u0439\u043d\u0435 \u0448\u0438\u0440\u043e\u043a\u0438\u043c.<\/p>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0434\u0430. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0438 \u0441\u043b\u0430\u0431\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438 \u0432\u044b\u0431\u043e\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0446\u0435\u043b\u0435\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u0442\u0440\u0435\u043d\u0434\u0430.<br \/> \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0432 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044f\u0445 \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a <a href=\"https:\/\/habr.com\/ru\/articles\/571058\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f,<\/a> \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f, \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u0438 \u0434\u0440\u0443\u0433\u0438\u0435. \u0418\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a ARIMA, SARIMA \u0438 \u0434\u0440\u0443\u0433\u0438\u0435.<\/p>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u043b\u044f\u0446\u0438\u044e \u0438 \u0433\u0435\u0442\u0435\u0440\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/www.statsmodels.org\/stable\/diagnostic.html\" rel=\"noopener noreferrer nofollow\">https:\/\/www.statsmodels.org\/stable\/diagnostic.html<\/a>.<\/p>\n<p>\u041e \u0442\u043e\u043c \u0447\u0435\u043c \u044d\u0442\u043e \u0447\u0440\u0435\u0432\u0430\u0442\u0430 \u043d\u0435\u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/articles\/781060\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/articles\/781060\/<\/a><\/p>\n<h2>\u0410\u0432\u0442\u043e\u0440\u044b<\/h2>\n<p><a href=\"https:\/\/www.linkedin.com\/in\/rudnitskiy\" rel=\"noopener noreferrer nofollow\">Roman Rudnitskiy<\/a><\/p>\n<p><a href=\"https:\/\/linkedin.com\/in\/marat-yuldashev\" rel=\"noopener noreferrer nofollow\">Marat Yuldashev<\/a><\/p>\n<p><a href=\"https:\/\/www.linkedin.com\/in\/m-tretyakov\" rel=\"noopener noreferrer nofollow\">Mikhail Tretyakov<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/795251\/\"> https:\/\/habr.com\/ru\/articles\/795251\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h4>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/787098\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 Habr \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u043e\u0446\u0435\u043d\u043a\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u0435\u0435 \u0441\u0442\u0430\u0446\u0438\u043e\u043d\u0430\u0440\u043d\u043e\u0441\u0442\u0438. \u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u0438, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u0435 \u0432 <a href=\"https:\/\/habr.com\/ru\/articles\/781060\/\" rel=\"noopener noreferrer nofollow\">A\/B \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438<\/a>, \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0435\u043d\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u0430\u044f \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0433\u043e\u0434\u0430 \u0432 \u0433\u043e\u0434, \u043e\u0446\u0435\u043d\u043a\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u0430 \u0434\u0432\u0430 \u0441\u043c\u0435\u0436\u043d\u044b\u0445 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430, \u0438 \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c.<\/p>\n<p>\u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d \u2014 \u0442\u0440\u0435\u043d\u0434 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0438 \u0447\u0430\u0441\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u043e\u0441\u0442 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u043b\u0430\u0433\u043e\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043d\u0430\u0441\u0435\u043b\u0435\u043d\u0438\u044f, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u0438\u043b\u0438 \u0441\u0435\u0437\u043e\u043d\u043d\u044b\u043c\u0438 \u0444\u0430\u043a\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0438\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0430\u0436\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<h2>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437<\/h2>\n<p>\u0412 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0438\u0433\u0440\u0430\u0435\u0442 \u0432\u0430\u0436\u043d\u0443\u044e \u0440\u043e\u043b\u044c \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0442\u0440\u0435\u043d\u0434\u0430, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f. \u0421\u0443\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u043f\u0440\u0438\u044f\u0442\u0438\u044f, \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 &#8212; \u043b\u0438\u0448\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0438\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u0438 \u0442\u0440\u0435\u043d\u0434\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u041e\u043d \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u0442\u0438\u043f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u044f\u0434\u0430 \u0438 \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b.<\/p>\n<p>\u041d\u0438\u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns   def generate_data(     n_samples: int,     loc: int = 100,     scale: int = 3,     trend_max: int = 20,     hetero: float = 1,     n_outliers: int = 0, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     metric_values = (         loc         + np.random.normal(scale=scale, size=n_samples)         * np.linspace(1, hetero, n_samples)         + np.linspace(0, trend_max, n_samples)     )      for i in range(n_outliers):         metric_values[i * n_samples \/\/ n_outliers] = np.max(metric_values) * 1.02      return pd.DataFrame({\"time\": time, \"metric\": metric_values})   def rolling_data(data, window_size=10):     return data.rolling(window=window_size).mean()   ONE_MONTH = 24 * 30 test_data_1 = generate_data(ONE_MONTH, hetero=1, trend_max=20, scale=3) test_data_2 = generate_data(ONE_MONTH, hetero=1, trend_max=20, scale=10) smoothed_data = rolling_data(test_data_2[\"metric\"])  fig, axes = plt.subplots(3, 1, figsize=(10, 12))  sns.lineplot(x=\"time\", y=\"metric\", data=test_data_1, ax=axes[0], alpha=0.5) axes[0].set_ylim(0, 200) axes[0].set_title(\"Low variance\")  sns.lineplot(x=\"time\", y=\"metric\", data=test_data_2, ax=axes[1], alpha=0.5) axes[1].set_ylim(0, 200) axes[1].set_title(\"High variance\")  axes[2].plot(test_data_2[\"time\"], smoothed_data, alpha=0.5, color=\"red\") axes[2].set_ylim(0, 200) axes[2].set_title(\"High variance and rolling window\")  plt.subplots_adjust(hspace=0.5) plt.show() <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0438\u0437\u043a\u0430\u044f, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u043c\u0435\u043d\u0435\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u0431\u043e\u043b\u0435\u0435 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0448\u0443\u043c\u043d\u044b\u0435, \u043a\u0430\u043a \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u044b\u043c. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0448\u0443\u043c\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0438\u043b\u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u0433\u043b\u0430\u0436\u0438\u0432\u0430\u043d\u0438\u0435. \u042d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0432\u043e\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0438 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0432 \u0430\u043d\u0430\u043b\u0438\u0437\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u043e\u043b\u044c\u0437\u044f\u0449\u0435\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0435, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0438\u0439 \u0442\u0440\u0435\u043d\u0434 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u043d\u0438\u0437\u0438\u0442 \u0435\u0433\u043e \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a \u043d\u043e\u0432\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0434\u0435\u0436\u043d\u043e.<\/p>\n<h2>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f<\/h2>\n<p>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u043e\u0446\u0435\u043d\u043a\u0438 \u0442\u0440\u0435\u043d\u0434\u0430. \u041e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0442\u044a\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e <a href=\"https:\/\/ocw.mit.edu\/courses\/18-655-mathematical-statistics-spring-2016\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0443\u0440\u0441\u043e\u0432<\/a> \u043f\u043e \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u0438 <a href=\"https:\/\/grow.google\/certificates\/data-analytics\/\" rel=\"noopener noreferrer nofollow\">\u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445<\/a>.<\/p>\n<p>\u041e\u0434\u043d\u043e \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430, \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c, \u043c\u0430\u043b\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u044f\u0445.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u043b\u044e\u0441 \u0432 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u043c\u0438\u043d\u0443\u0441\u043e\u043c &#8212; \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0433\u0438\u0431\u043a\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0441\u0432\u044f\u0437\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u043d\u0434 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0435\u0432\u0435\u0440\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<p>\u041b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c). \u041d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u0430\u043c.<\/p>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u0430\u043c<\/p>\n<ul>\n<li>\n<p><strong>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u0438.<\/strong> <\/p>\n<ul>\n<li>\n<p>\u0413\u043e\u043c\u043e\u0441\u043a\u0435\u0434\u0430\u0441\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0440\u0435\u0434\u0438\u043a\u0442\u043e\u0440\u043e\u0432. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u043e\u0448\u0438\u0431\u043e\u043a \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 <a href=\"https:\/\/studfile.net\/preview\/2069367\/page:20\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442<\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Breusch-Pagan test.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c <\/strong>R\u00b2<strong> \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0443\u0433\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430.<\/strong> <\/p>\n<ul>\n<li>\n<p>R\u00b2 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u043e\u0434\u0435\u043b\u0438. \u0427\u0435\u043c \u043e\u043d \u0431\u043b\u0438\u0436\u0435 \u043a 1, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b-\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u044e. \u041d\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0438\u0437\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f R\u00b2 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u044e\u0442 \u043e \u043d\u0435\u0441\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0447\u0435\u043d\u044c \u0448\u0443\u043c\u043d\u044b\u0435 \u0438 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u044b, R\u00b2 \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0438\u0437\u043a\u0438\u043c, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438\u043b\u0438 \u044f\u0432\u043d\u043e\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430. \u0414\u0435\u0442\u0430\u043b\u044c\u043d\u0435\u0439 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0438\u0436\u0435.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a<\/strong> <\/p>\n<ul>\n<li>\n<p>\u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0432\u0430\u0436\u043d\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u043e\u0446\u0435\u043d\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430, \u0442\u0430\u043a\u0430\u044f \u043a\u0430\u043a \u0442\u0435\u0441\u0442 \u0414\u0430\u0440\u0431\u0438\u043d\u0430-\u0423\u043e\u0442\u0441\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 \u0432 \u043e\u0441\u0442\u0430\u0442\u043a\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0439 \u0441 \u043d\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/articles\/693402\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u0431\u044b\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0414\u0430\u0440\u0431\u0438\u043d\u0430-\u0423\u043e\u0442\u0441\u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 1.5 \u0434\u043e 2.5, \u044d\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438. \u041e\u0434\u043d\u0430\u043a\u043e, \u0434\u043b\u044f \u0442\u043e\u0447\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0414\u0430\u0440\u0431\u0438\u043d\u0430-\u0423\u043e\u0442\u0441\u043e\u043d\u0430 \u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442 p-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430.<\/strong> <\/p>\n<ul>\n<li>\n<p>\u041e \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0417\u0434\u0435\u0441\u044c \u043b\u0438\u0448\u044c \u0443\u0442\u043e\u0447\u043d\u0438\u043c \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0448\u0438\u0440\u043e\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c. \u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 1000 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0443\u0442\u0441\u0440\u0430\u043f\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0443\u0433\u043e\u043b \u043d\u0430\u043a\u043b\u043e\u043d\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0440\u0435\u043d\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0430\u043b\u0435\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0435\u043d\u0434\u0430 \u043d\u0430 Python \u0438 Scipy , \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0440\u0435\u0433\u0440\u0435\u0441\u0441\u0438\u0438.<\/p>\n<p>\u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c  \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt  import numpy as np  import pandas as pd import scipy.stats as stats  import seaborn as sns import statsmodels.api as sm   def generate_data(     n_samples: int,     loc: int = 100,     scale: int = 10,     trend_max: int = 10,     hetero: float = 2, ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")      metric_values = (         loc         + np.random.normal(scale=scale, size=n_samples)         * np.linspace(1, hetero, n_samples)         + np.linspace(0, trend_max, n_samples)     )      return pd.DataFrame({\"time\": time, \"metric\": metric_values})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH)  # plot data  sns.lineplot(x=\"time\", y=\"metric\", data=test_data, alpha=0.5) # fit linear regression slope, intercept, rvalue, pvalue, stderr = stats.linregress(     test_data.index, test_data.metric )  # test for Homoscedasticity of the residuals   def test_homoscedasticity(test_data: pd.DataFrame):     # prepare y and X for statsmodels     y = test_data.metric     X_sm = test_data.index     X_sm = sm.add_constant(X_sm)     # fit linear regression using statsmodels     mod_sm = sm.OLS(y, X_sm)     res_sm = mod_sm.fit()     # test for Homoscedasticity     bp_lm, bp_lm_pvalue, bp_fvalue, bp_f_pvalue = sm.stats.diagnostic.het_breuschpagan(         res_sm.resid, res_sm.model.exog     )      return bp_f_pvalue   bp_f_pvalue = test_homoscedasticity(test_data) if bp_f_pvalue &lt; 0.05:     print(\"Residuals are not Homoscedastic. Linear regression may be invalid\") else:     print(\"Residuals are Homoscedastic\")   # test autocorrelation def test_autocorrelation(residuals):     dw_statistic = sm.stats.durbin_watson(residuals)     return dw_statistic   # Assuming you have the 'residuals' variable defined elsewhere in your code # Conduct the test for autocorrelation   # Check the p-value and print the result residuals = test_data.metric - (intercept + slope * test_data.index) dw_statistic = test_autocorrelation(residuals)  if dw_statistic > 1.5 and 2.5:     print(\"Errors are independent (no signs of autocorrelation)\") else:     print(         \"\u0410utocorrelation in the residuals. Independence of errors is not satisfactory.\"     )  # bootstrap linear regression slope n_iterations = 1000 slopes = np.zeros(n_iterations) intercepts = np.zeros(n_iterations) r_square = np.zeros(n_iterations) for i in range(n_iterations):     sample = test_data.sample(frac=1, replace=True)     slope, intercept, rvalue, pvalue, stderr = stats.linregress(         sample.index, sample.metric     )     slopes[i] = slope     intercepts[i] = intercept     r_square[i] = rvalue**2 # calculate 95% confidence interval slopes_quantiles = np.percentile(slopes, [2.5, 97.5]) intercept_quantiles = np.percentile(intercepts, [2.5, 97.5]) r_square_quantiles = np.percentile(r_square, [2.5, 97.5])<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-368817","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368817"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368817\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}