{"id":365561,"date":"2024-05-21T02:40:51","date_gmt":"2024-05-21T02:40:51","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=365561"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=365561","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 \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0430\u0441\u0442\u044c 1. \u0423\u043f\u0430\u043b\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430<\/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<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/781060\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0410\u0411 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441 \u043d\u0438\u043c\u0438 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f. \u041d\u043e \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0410\u0411 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u043b\u044c\u0437\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0445 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0439 \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u043c\u0430\u0441\u0441\u043e\u0432\u0443\u044e \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044e. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u0430\u0447\u043d\u0443\u0442 \u043c\u0430\u0441\u0441\u043e\u0432\u043e \u043f\u0435\u0440\u0435\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0422\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043e\u0442\u0437\u044b\u0432\u043e\u0432 \u0438\u0437-\u0437\u0430 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0446\u0438\u0438. \u041d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0446\u0435\u043d\u043a\u0438 \u0442\u0430\u043a\u0438\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c. \u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442\u0441\u044f, \u0442\u043e \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u0430 \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0443\u0445\u0443\u0434\u0448\u0438\u043b\u0430\u0441\u044c, \u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430. \u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 &#8212; \u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0443\u043f\u0430\u043b\u0430 \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u0441\u043c\u044b\u0441\u043b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435?<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c &#8212; \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u0441\u0442\u043e\u0438\u0442 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c? \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u044f\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u043c \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0435\u0439\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u0441\u0430\u043c\u043e\u043a\u0430\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442. \u0426\u0435\u043b\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0432\u044b\u043c \u0433\u043e\u0434\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0430 \u043c\u0430\u0441\u0441\u043e\u0432\u0430\u044f \u0440\u0435\u043a\u043b\u0430\u043c\u0430 \u0441 \u0440\u0430\u0437\u0434\u0430\u0447\u0435\u0439 \u043f\u0440\u043e\u043c\u043e \u043a\u043e\u0434\u043e\u0432 \u0441\u043e \u0441\u043a\u0438\u0434\u043a\u0430\u043c\u0438 \u043d\u0430 \u043a\u0440\u0430\u0441\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u043a\u0430\u0442\u044b. \u041a\u0430\u043a \u0438\u0442\u043e\u0433 &#8212; \u043e\u0431\u0449\u0430\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0443\u043f\u0430\u043b\u0430. \u041e\u043f\u044b\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u044f\u0432\u0438\u0442, \u0447\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434\u044b, \u043d\u043e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0435\u043d \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441 \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434\u0430\u043c\u0438 \u0438 \u043c\u043e\u0433\u043b\u0438 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434\u0430\u043c\u0438 \u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u0441\u0430\u043c\u043e\u043a\u0430\u0442\u043e\u0432 \u0432 \u0434\u043e\u043b\u0435 \u043f\u0440\u043e\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0441 \u0447\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435. \u041e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u043d\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0433\u043e\u0434\u0430 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u0433\u0435\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u041d\u043e \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0410\u0411 \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u043d\u0430 100% \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438? \u0415\u0441\u043b\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0433\u043e 5-10, \u0438 \u043e\u043d\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u044b, \u0442\u043e \u0441\u043c\u044b\u0441\u043b \u0432 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u043e\u043c &#8212; \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u2013 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/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   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(n_samples: int) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=100, scale=10, size=n_samples \/\/ 2),             np.random.normal(loc=95, scale=10, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2) print(test_data.head())  sns.lineplot(x=\"time\", y=\"metric\", data=test_data) 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\/70e\/bb3\/774\/70ebb37746fa74bb8e1c6b2a921e798b.png\" alt=\"\u0421\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0448\u0443\u043c\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 metric \u0437\u0430 \u0434\u0432\u0430 \u043c\u0435\u0441\u044f\u0446\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439.\" title=\"\u0421\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0448\u0443\u043c\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 metric \u0437\u0430 \u0434\u0432\u0430 \u043c\u0435\u0441\u044f\u0446\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439.\" width=\"1752\" height=\"854\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/70e\/bb3\/774\/70ebb37746fa74bb8e1c6b2a921e798b.png\"\/><\/p>\n<div><figcaption>\u0421\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0448\u0443\u043c\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 metric \u0437\u0430 \u0434\u0432\u0430 \u043c\u0435\u0441\u044f\u0446\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439.<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u0435\u0442\u0440\u0438\u043a\u0430 \u0448\u0443\u043c\u043d\u0430\u044f, \u0447\u0442\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0434\u0432\u0443\u0445 \u0442\u043e\u0447\u0435\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043a\u0430\u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043e\u0431\u0449\u0435\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u043d\u0438\u0436\u0435. \u041a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c?<\/p>\n<h2>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/h2>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u043d\u0430\u0439\u0442\u0438 \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u043d\u0430 \u043f\u0440\u0435\u0434 \u043f\u0435\u0440\u0438\u043e\u0434\u0435, \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u043d\u0430 \u043f\u043e\u0441\u0442 \u043f\u0435\u0440\u0438\u043e\u0434\u0435 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>Python \u00a0\u043a\u043e\u0434<\/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   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(n_samples: int) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=100, scale=10, size=n_samples \/\/ 2),             np.random.normal(loc=95, scale=10, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2) print(test_data.head())   # \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0435 \u0438 \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0435 avg_1m = test_data.iloc[:ONE_MONTH].metric.mean() avg_2m = test_data.iloc[ONE_MONTH:].metric.mean()   sns.lineplot(x=\"time\", y=\"metric\", data=test_data) # \u0413\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0435\u0439 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 plt.hlines(     y=avg_1m,     xmin=test_data.iloc[0].time,     xmax=test_data.iloc[ONE_MONTH - 1].time,     color=\"red\", )   plt.hlines(     y=avg_2m,     xmin=test_data.iloc[ONE_MONTH].time,     xmax=test_data.iloc[-1].time,     color=\"red\", )  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\/3fa\/0d6\/a28\/3fa0d6a288544bb2bff69eb7c752de4e.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0445\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0445\" width=\"1800\" height=\"856\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3fa\/0d6\/a28\/3fa0d6a288544bb2bff69eb7c752de4e.png\"\/><\/p>\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u0440\u0435\u0434\u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0432\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0443\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0443\u043b\u0435\u0432\u0430\u044f. \u0412 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u0440\u0430\u0432\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437-\u0437\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u0439. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<h2>\u0422\u0435\u0441\u0442 \u0421\u0442\u044c\u044e\u0434\u0435\u043d\u0442\u0430<\/h2>\n<p>t-\u0442\u0435\u0441\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041f\u0440\u0438 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u0445\u0438-\u043a\u0432\u0430\u0434\u0440\u0430\u0442-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e,<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, QQ-plot, \u043b\u0438\u0431\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u0428\u0430\u043f\u0438\u0440\u043e-\u0412\u0438\u043b\u043a\u0430, \u041a\u043e\u043b\u043c\u043e\u0433\u043e\u0440\u043e\u0432\u0430-\u0421\u043c\u0438\u0440\u043d\u043e\u0432\u0430, \u0438 \u0434\u0440\u0443\u0433\u0438\u0445). \u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u043e, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/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   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(     n_samples: int, loc1: int = 100, scale1: int = 10, loc2: int = 99, scale2: int = 10 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=loc1, scale=scale1, size=n_samples \/\/ 2),             np.random.normal(loc=loc2, scale=scale2, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2) data_month1 = test_data.iloc[:ONE_MONTH].metric data_month2 = test_data.iloc[ONE_MONTH:].metric   # \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0442\u0435\u0441\u0442 \u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u0441\u044f\u0446\u0430 # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0434\u043b\u044f \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043e\u043a def sample_means(data, n_samples=100, n_iterations=1000):     means = np.zeros(n_iterations)     for i in range(n_iterations):         sample = np.random.choice(data, size=n_samples, replace=True)         means[i] = sample.mean()     return means   month_1_means = sample_means(data_month1) month_2_means = sample_means(data_month2)   if stats.shapiro(month_1_means).pvalue &lt; 0.05:     print(\"Month 1 means are not normally distributed. Can't use t-test\") if stats.shapiro(month_2_means).pvalue &lt; 0.05:     print(\"Month 2 means are not normally distributed. Can't use t-test\")  fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5)) # QQ-\u0433\u0440\u0430\u0444\u0438\u043a \u0434\u043b\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 stats.probplot(month_1_means, dist=\"norm\", plot=ax1)   # \u0442\u0435\u0441\u0442 \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 chi2 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0437\u0430 1-\u0439 \u0438 2-\u0439 \u043c\u0435\u0441\u044f\u0446\u044b def sample_variances(data, n_iterations=1000):     variances = np.zeros(n_iterations)     for i in range(n_iterations):         sample = np.random.choice(data, size=len(data), replace=True)         variances[i] = sample.var()     return variances   # \u0433\u0440\u0430\u0444\u0438\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e\u0439 \u0434\u0438\u0441\u043f\u0440\u0435\u0441\u0438\u0438 \u0437\u0430 \u043c\u0435\u0441\u044f\u0446 1 \u043f\u043e \u043e\u0441\u0438 ax2 month1_variances = sample_variances(data_month1) n1 = len(data_month1) sns.histplot(     month1_variances * (n1 - 1) \/ data_month1.var(),     stat=\"density\",     label=\"sample variance\",     ax=ax2, )  # \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f chi2 \u0441 n1-1 \u0441\u0442\u0435\u043f\u0435\u043d\u044f\u043c\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u044b \u043d\u0430 ax2 x = np.linspace(500, 1000, 1000) ax2.plot(x, stats.chi2.pdf(x, n1 - 1), color=\"red\", linewidth=2, alpha=0.5) ax2.set_xlabel(\"Sample variance\") ax2.set_ylabel(\"Density\") plt.show()  print(f\"p-value: {stats.ttest_ind(month_1_means, month_2_means).pvalue:.3f}\") <\/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\/10b\/bd6\/c9e\/10bbd6c9e9bddf61c9dc8458a49726da.png\" alt=\"\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 t-test\" title=\"\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 t-test\" width=\"1716\" height=\"926\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/10b\/bd6\/c9e\/10bbd6c9e9bddf61c9dc8458a49726da.png\"\/><\/p>\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 t-test<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b.<\/p>\n<h2>\u0422\u0435\u0441\u0442 \u041c\u0430\u043d\u043d\u0430-\u0423\u0438\u0442\u043d\u0438<\/h2>\n<p>\u041c\u0430\u043d\u0430-\u0423\u0438\u0442\u043d\u0438, U-test. \u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/habr.com\/ru\/companies\/avito\/articles\/709596\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f 1000 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u0432\u0443\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0438 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import scipy.stats as stats   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(     n_samples: int, loc1: int = 100, scale1: int = 10, loc2: int = 99, scale2: int = 10 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=loc1, scale=scale1, size=n_samples \/\/ 2),             np.random.normal(loc=loc2, scale=scale2, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 log_false_positives_t = [] log_false_positives_u = [] for _ in range(1000):     test_data = generate_data(ONE_MONTH * 2, loc1=100, loc2=100, scale1=10, scale2=100)      data_month1 = test_data.iloc[:ONE_MONTH].metric     data_month2 = test_data.iloc[ONE_MONTH:].metric      u_test_results = stats.mannwhitneyu(data_month1, data_month2)     t_test_results = stats.ttest_ind(data_month1, data_month2)      log_false_positives_t.append(t_test_results.pvalue &lt; 0.05)     log_false_positives_u.append(u_test_results.pvalue &lt; 0.05)  print(f\"False positives for t-test: {np.mean(log_false_positives_t):.3f}\") print(f\"False positives for U-test: {np.mean(log_false_positives_u):.3f}\") <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>U-test \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0434\u0430\u0451\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 (\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0432 5% \u0441\u043b\u0443\u0447\u0430\u0435\u0432) \u0447\u0435\u043c t-test \u043f\u0440\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 alpha = 0.05. \u041f\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442 \u0442\u0435\u0441\u0442 \u041a\u043e\u043b\u043c\u043e\u0433\u043e\u0440\u043e\u0432\u0430-\u0421\u043c\u0438\u0440\u043d\u043e\u0432\u0430 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0435\u0441\u0442\u044b, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d, \u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u0445.<\/p>\n<h2>\u0411\u0443\u0442\u0441\u0442\u0440\u0430\u043f<\/h2>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c 1000 \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0447\u0435\u0440\u0435\u0437 \u043a\u0432\u0430\u043d\u0442\u0438\u043b\u0438. \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u044c \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u043e\u0447\u0435\u043d\u044c \u0448\u0438\u0440\u043e\u043a\u0430, \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b. \u0411\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0430\u043a \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0434\u043b\u044f \u043f\u043e\u0441\u0442 \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0438 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a \u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u0445. \u0415\u0441\u043b\u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 0, \u0442\u043e \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u0430. \u0425\u043e\u0440\u043e\u0448\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043e \u0432 \u043a\u043d\u0438\u0433\u0435 Efron B. Bootstrap confidence intervals for a class of parametric problems, Biometrika 1985.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0431\u0440\u043e\u0441\u044b \u0438\u043b\u0438 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043e\u0446\u0435\u043d\u043a\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0443\u0447\u0442\u0435\u043d\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u044b. \u0410\u043d\u0430\u043b\u0438\u0437 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0438 \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.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u0432\u044b\u0431\u0440\u043e\u0441\u043e\u0432 \u0438\u043b\u0438 \u0433\u0440\u044f\u0437\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043b\u043e\u0445\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445. \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0432\u044b\u0431\u0440\u043e\u0441\u044b \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445, \u0438 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043e\u0446\u0435\u043d\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u0411\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0432\u044b\u0431\u0440\u043e\u0441\u0430\u043c\u0438 \u0438\u043b\u0438 \u043d\u0435\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0427\u0442\u043e \u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043f\u0443\u0442\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0441 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043e\u043a, \u0430 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0432\u043e\u0439\u0442\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u044b. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u0443\u044e \u0434\u043b\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432\u0430\u0436\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043b\u0438 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438), \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0430\u0441\u043f\u0435\u043a\u0442. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0431\u043e\u043b\u0435\u0435 \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0443\u0447\u0435\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import matplotlib.pyplot as plt import numpy as np import pandas as pd   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(     n_samples: int, loc1: int = 100, scale1: int = 10, loc2: int = 95, scale2: int = 10 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=loc1, scale=scale1, size=n_samples \/\/ 2),             np.random.normal(loc=loc2, scale=scale2, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   # \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2)   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f\u0430 \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 def bootstrap_and_plot(data, num_samples=1000, alpha=0.05):     sample_means_post = []     sample_means_pre = []     sample_diff_means = []      for _ in range(num_samples):         bootstrap_sample = data.sample(frac=1, replace=True)          # \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0430 \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434 \u0438 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434         post_period = bootstrap_sample[bootstrap_sample[\"time\"] >= \"2024-02-01\"][             \"metric\"         ]         pre_period = bootstrap_sample[bootstrap_sample[\"time\"] &lt; \"2024-02-01\"][\"metric\"]          # \u0420\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0438 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0430         sample_mean_post = post_period.mean()         sample_mean_pre = pre_period.mean()         sample_means_post.append(sample_mean_post)         sample_means_pre.append(sample_mean_pre)          # \u0420\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0441\u0440\u0435\u0434\u043d\u0438\u0445         sample_diff_means.append(sample_mean_post - sample_mean_pre)      # \u0420\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430, \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0441\u0440\u0435\u0434\u043d\u0438\u0445     lower_bound_post = np.percentile(sample_means_post, (alpha \/ 2) * 100)     upper_bound_post = np.percentile(sample_means_post, (1 - alpha \/ 2) * 100)      lower_bound_pre = np.percentile(sample_means_pre, (alpha \/ 2) * 100)     upper_bound_pre = np.percentile(sample_means_pre, (1 - alpha \/ 2) * 100)      lower_bound_diff = np.percentile(sample_diff_means, (alpha \/ 2) * 100)     upper_bound_diff = np.percentile(sample_diff_means, (1 - alpha \/ 2) * 100)      # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432     plt.figure(figsize=(15, 5))      plt.subplot(1, 3, 1)     plt.hist(sample_means_post, bins=30, edgecolor=\"black\", alpha=0.7)     plt.axvline(         lower_bound_post,         color=\"red\",         linestyle=\"dashed\",         linewidth=2,         label=f\"Lower Bound ({alpha * 100}% CI)\",     )     plt.axvline(         upper_bound_post,         color=\"green\",         linestyle=\"dashed\",         linewidth=2,         label=f\"Upper Bound ({(1 - alpha) * 100}% CI)\",     )     plt.xlabel(\"Post-Period Bootstrap Sample Means\")     plt.ylabel(\"Frequency\")     plt.legend()     plt.title(\"Post-Period Bootstrap Sampling Distribution\")      plt.subplot(1, 3, 2)     plt.hist(sample_means_pre, bins=30, edgecolor=\"black\", alpha=0.7)     plt.axvline(         lower_bound_pre,         color=\"red\",         linestyle=\"dashed\",         linewidth=2,         label=f\"Lower Bound ({alpha * 100}% CI)\",     )     plt.axvline(         upper_bound_pre,         color=\"green\",         linestyle=\"dashed\",         linewidth=2,         label=f\"Upper Bound ({(1 - alpha) * 100}% CI)\",     )     plt.xlabel(\"Pre-Period Bootstrap Sample Means\")     plt.ylabel(\"Frequency\")     plt.legend()     plt.title(\"Pre-Period Bootstrap Sampling Distribution\")      plt.subplot(1, 3, 3)     plt.hist(sample_diff_means, bins=30, edgecolor=\"black\", alpha=0.7)     plt.axvline(         lower_bound_diff,         color=\"red\",         linestyle=\"dashed\",         linewidth=2,         label=f\"Lower Bound ({alpha * 100}% CI)\",     )     plt.axvline(         upper_bound_diff,         color=\"green\",         linestyle=\"dashed\",         linewidth=2,         label=f\"Upper Bound ({(1 - alpha) * 100}% CI)\",     )     plt.xlabel(\"Difference in Bootstrap Sample Means (Post-Period - Pre-Period)\")     plt.ylabel(\"Frequency\")     plt.legend()     plt.title(\"Difference in Bootstrap Sampling Distribution\")      plt.tight_layout()     plt.show()      return (         (lower_bound_post, upper_bound_post),         (lower_bound_pre, upper_bound_pre),         (lower_bound_diff, upper_bound_diff),     )   # \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b ci_post, ci_pre, ci_diff = bootstrap_and_plot(test_data)   # \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b print(f\"\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430: ({ci_post[0]:.2f}, {ci_post[1]:.2f})\") print(f\"\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0430: ({ci_pre[0]:.2f}, {ci_pre[1]:.2f})\") print(     f\"\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0441\u0440\u0435\u0434\u043d\u0438\u0445: ({ci_diff[0]:.2f}, {ci_diff[1]:.2f})\" )  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0441\u0440\u0435\u0434\u043d\u0438\u0445 if ci_diff[0] > 0 or ci_diff[1] &lt; 0:     print(\"\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u0430.\") else:     print(\"\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0439.\") <\/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\/853\/267\/8ac\/8532678ac5d0cec943eed99b4aad7063.png\" width=\"2888\" height=\"930\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/853\/267\/8ac\/8532678ac5d0cec943eed99b4aad7063.png\"\/><\/figure>\n<p>\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430: (94.03, 95.58)<\/p>\n<p>\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0430: (99.28, 100.73)<\/p>\n<p>\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u0441\u0440\u0435\u0434\u043d\u0438\u0445: (-6.19, -4.20). \u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b.<\/p>\n<h2>\u0422\u0435\u0441\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a<\/h2>\n<p>\u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f, \u043d\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u043c\u0438 \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0445\u043e\u0442\u044f \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439. \u0415\u0441\u043b\u0438 \u0431\u0443\u0442\u0441\u0442\u0440\u0430\u043f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 1000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0441\u0435\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 100000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043a\u043d\u0438\u0433\u0435 Bootstrap Methods And Permutation Tests Companion Chapter 18 To The Practice Of Business Statistics).<\/p>\n<p>\u0422\u0435\u0441\u0442 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0430 \u0438\u0434\u0435\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u0438 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u043f\u0440\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430\u0445 \u043c\u0435\u0442\u043e\u043a \u0433\u0440\u0443\u043f\u043f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u043f\u0443\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u044b \u043e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np import pandas as pd   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(     n_samples: int, loc1: int = 100, scale1: int = 10, loc2: int = 95, scale2: int = 10 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=loc1, scale=scale1, size=n_samples \/\/ 2),             np.random.normal(loc=loc2, scale=scale2, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   # \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2)  # \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0430 \u043c\u0435\u0441\u044f\u0446 1 \u0438 \u043c\u0435\u0441\u044f\u0446 2 data_month1 = test_data.iloc[:ONE_MONTH].metric data_month2 = test_data.iloc[ONE_MONTH:].metric  # \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0441\u0440\u0435\u0434\u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 observed_diff = np.mean(data_month1) - np.mean(data_month2)  # \u041e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 all_data = np.concatenate((data_month1, data_month2))  # \u0417\u0430\u0434\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a num_permutations = 100000 np.random.seed(42)  # \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u0441\u0440\u0435\u0434\u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 permuted_diffs = np.zeros(num_permutations) for i in range(num_permutations):     np.random.shuffle(all_data)     permuted_diffs[i] = np.mean(all_data[:ONE_MONTH]) - np.mean(all_data[ONE_MONTH:])  # \u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c p-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 p_value = np.sum(permuted_diffs >= observed_diff) \/ num_permutations  # \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b print(f\"P-value \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430: {p_value:.3f}\")  # \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0437\u043d\u0430\u0447\u0438\u043c\u043e\u0441\u0442\u044c alpha = 0.05 if p_value &lt; alpha:     print(\"\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u043e.\") else:     print(\"\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c.\") <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>P-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 0.05. \u0420\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u043e (alpha = 0.05).<\/p>\n<h2>\u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0438\u043c\u0435\u0435\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0422\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u043c \u0438 \u043a\u0430\u043a\u043e\u0439 \u0443 \u043d\u0435\u0433\u043e \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b. \u0422\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430. \u0422\u043e\u0433\u0434\u0430 \u0441\u0440\u0430\u0432\u043d\u0438\u0432 \u0434\u0432\u0430 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043e \u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0438. \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430, \u043f\u0440\u0438 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0435. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0438 \u0442\u0438\u043f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445.<\/p>\n<p>\u0425\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/www.pymc.io\/projects\/docs\/en\/latest\/learn\/core_notebooks\/pymc_overview.html\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 pymc<\/a>, \u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0434\u0430\u043b\u0435\u043a\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u0414\u0430\u043b\u0435\u0435 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438\u0437 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430 \u0434\u0435\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043b\u0438\u0448\u043d\u0438\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e (\u0438\u043b\u0438 \u0436\u0435 \u0438\u043d\u0430\u0447\u0435 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0430\u0448\u0435\u0439 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b). <\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import arviz as az import matplotlib.pyplot as plt import numpy as np import pandas as pd import pymc as pm   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(     n_samples: int, loc1: int = 100, scale1: int = 10, loc2: int = 95, scale2: int = 10 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=loc1, scale=scale1, size=n_samples \/\/ 2),             np.random.normal(loc=loc2, scale=scale2, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   # \u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2) # \u0420\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434 \u0438 \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434 data_prior = test_data.iloc[:ONE_MONTH].metric.values data_posterior = test_data.iloc[ONE_MONTH:].metric.values # \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0430 with pm.Model() as prior_model:     mu_prior = pm.Normal(\"mu_prior\", mu=np.mean(data_prior), sigma=np.std(data_prior))     sigma_prior = pm.HalfNormal(\"sigma_prior\", sigma=np.std(data_prior))     likelihood_prior = pm.Normal(         \"likelihood_prior\", mu=mu_prior, sigma=sigma_prior, observed=data_prior     )     prior_trace = pm.sample(2000, tune=1000) # \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430 with pm.Model() as posterior_model:     mu_posterior = pm.Normal(         \"mu_posterior\", mu=np.mean(data_posterior), sigma=np.std(data_posterior)     )     sigma_posterior = pm.HalfNormal(\"sigma_posterior\", sigma=np.std(data_posterior))     likelihood_posterior = pm.Normal(         \"likelihood_posterior\",         mu=mu_posterior,         sigma=sigma_posterior,         observed=data_posterior,     )     posterior_trace = pm.sample(2000, tune=1000)  plt.figure(figsize=(20, 1))  # \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 prior_interval_hdi = az.hdi(prior_trace, hdi_prob=0.95) posterior_interval_hdi = az.hdi(posterior_trace, hdi_prob=0.95)  prior_interval = [     prior_interval_hdi.sel(hdi=\"lower\")[\"mu_prior\"].item(),     prior_interval_hdi.sel(hdi=\"higher\")[\"mu_prior\"].item(), ] posterior_interval = [     posterior_interval_hdi.sel(hdi=\"lower\")[\"mu_posterior\"].item(),     posterior_interval_hdi.sel(hdi=\"higher\")[\"mu_posterior\"].item(), ]  # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0434\u043b\u044f mu_prior plt.figure(figsize=(12, 6)) az.plot_posterior(prior_trace, var_names=[\"mu_prior\"], hdi_prob=0.95) plt.title(\"Prior Distribution for mu with 95% HDI\") plt.show()  # \u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0434\u043b\u044f mu_posterior plt.figure(figsize=(12, 6)) az.plot_posterior(posterior_trace, var_names=[\"mu_posterior\"], hdi_prob=0.95) plt.title(\"Posterior Distribution for mu with 95% HDI\") plt.show()  # \u0412\u044b\u0432\u043e\u0434 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 print(f\"\u041f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434: ({prior_interval[0]:.2f}, {prior_interval[1]:.2f})\") print(f\"\u041f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434: ({posterior_interval[0]:.2f}, {posterior_interval[1]:.2f})\")  if (     prior_interval[1] >= posterior_interval[0]     and prior_interval[0] &lt;= posterior_interval[1] ):     print(\"\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f, \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c.\") # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 else:     print(\"\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f, \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u043e.\") <\/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\/f54\/075\/a93\/f54075a93f0e1def13a6648c2fba428b.png\" width=\"1048\" height=\"878\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f54\/075\/a93\/f54075a93f0e1def13a6648c2fba428b.png\"\/><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/818\/500\/dc8\/818500dc84ab4024bb414b8b500b9e09.png\" width=\"1050\" height=\"868\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/818\/500\/dc8\/818500dc84ab4024bb414b8b500b9e09.png\"\/><\/figure>\n<p>\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0430: (99.48, 100.89)<\/p>\n<p>\u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0430: (94.03, 95.50)<\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f, \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u043e<\/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 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432, \u043d\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043c\u0430\u0448\u0438\u043d\u043d\u044b\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c, \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u0434\u0445\u043e\u0434\u044b causal inference, Difference in Difference, \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/engineering.atspotify.com\/2023\/09\/how-to-accurately-test-significance-with-difference-in-difference-models\/\" rel=\"noopener noreferrer nofollow\"><u>Spotify<\/u><\/a>, &#171;Causal Inference in Statistics: A Primer&#187; by Judea Pearl, &#171;Counterfactuals and Causal Inference: Methods and Principles for Social Research&#187; by Stephen L. Morgan and Christopher Winship, \u0438 \u0434\u0440\u0443\u0433\u0438\u0445. <\/p>\n<p>\u041e\u043f\u044b\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a \u043e\u0442\u043c\u0435\u0442\u0438\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u044b\u0439 \u043d\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0442\u0440\u0435\u043d\u0434, \u0442\u043e \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0441\u0442\u043e\u0438\u0442 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u043a\u0442\u043e\u0440, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0435 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0443\u0432\u0438\u0434\u0438\u043c \u0437\u0430\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e. \u0427\u0430\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u0447\u0435\u0441\u0442\u044c \u0442\u0440\u0435\u043d\u0434, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0430 \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0440\u0435\u043d\u0434? \u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/795251\/\" rel=\"noopener noreferrer nofollow\">\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u0442\u0440\u0435\u043d\u0434\u0430 \u0438 \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<\/p>\n<h2>\u0410\u0432\u0442\u043e\u0440\u044b<\/h2>\n<p><a href=\"https:\/\/linkedin.com\/in\/anastasia-zaremba-malakhova-474072159\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u0440\u0435\u043c\u0431\u0430 \u0410\u043d\u0430\u0441\u0442\u0430\u0441\u0438\u044f<\/a><\/p>\n<p><a href=\"https:\/\/linkedin.com\/in\/rudnitskiy\" rel=\"noopener noreferrer nofollow\">\u0420\u0443\u0434\u043d\u0438\u0446\u043a\u0438\u0439 \u0420\u043e\u043c\u0430\u043d<\/a><\/p>\n<p><a href=\"https:\/\/www.linkedin.com\/in\/marat-yuldashev\" rel=\"noopener noreferrer nofollow\">\u042e\u043b\u0434\u0430\u0448\u0435\u0432 \u041c\u0430\u0440\u0430\u0442<\/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\/787098\/\"> https:\/\/habr.com\/ru\/articles\/787098\/<\/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<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/781060\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0410\u0411 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441 \u043d\u0438\u043c\u0438 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f. \u041d\u043e \u0447\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0410\u0411 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u043d\u0435\u043b\u044c\u0437\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u0442\u0438\u043f\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0445 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u0439 \u043d\u0430\u0446\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u043c\u0430\u0441\u0441\u043e\u0432\u0443\u044e \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044e. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u0438\u0440\u0443\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043d\u0430\u0447\u043d\u0443\u0442 \u043c\u0430\u0441\u0441\u043e\u0432\u043e \u043f\u0435\u0440\u0435\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0422\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u043e\u0442\u0437\u044b\u0432\u043e\u0432 \u0438\u0437-\u0437\u0430 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0439 \u0434\u0438\u0441\u043a\u0440\u0438\u043c\u0438\u043d\u0430\u0446\u0438\u0438. \u041d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u0446\u0435\u043d\u043a\u0438 \u0442\u0430\u043a\u0438\u0445 \u043d\u043e\u0432\u043e\u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0448\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c. \u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0442\u0441\u044f, \u0442\u043e \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439, \u0430 \u0435\u0441\u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0443\u0445\u0443\u0434\u0448\u0438\u043b\u0430\u0441\u044c, \u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430. \u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 &#8212; \u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u0443\u043f\u0430\u043b\u0430 \u0438 \u0435\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u0441\u043c\u044b\u0441\u043b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435?<\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c &#8212; \u043d\u0430 \u043a\u0430\u043a\u0443\u044e \u0438\u043c\u0435\u043d\u043d\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u0441\u0442\u043e\u0438\u0442 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c? \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u044f\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u043c \u0432 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0435\u0439\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u0441\u0430\u043c\u043e\u043a\u0430\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442. \u0426\u0435\u043b\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0432\u044b\u043c \u0433\u043e\u0434\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b\u0430 \u043c\u0430\u0441\u0441\u043e\u0432\u0430\u044f \u0440\u0435\u043a\u043b\u0430\u043c\u0430 \u0441 \u0440\u0430\u0437\u0434\u0430\u0447\u0435\u0439 \u043f\u0440\u043e\u043c\u043e \u043a\u043e\u0434\u043e\u0432 \u0441\u043e \u0441\u043a\u0438\u0434\u043a\u0430\u043c\u0438 \u043d\u0430 \u043a\u0440\u0430\u0441\u043d\u044b\u0435 \u0441\u0430\u043c\u043e\u043a\u0430\u0442\u044b. \u041a\u0430\u043a \u0438\u0442\u043e\u0433 &#8212; \u043e\u0431\u0449\u0430\u044f \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 \u0443\u043f\u0430\u043b\u0430. \u041e\u043f\u044b\u0442\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a \u0441\u0440\u0430\u0437\u0443 \u0432\u044b\u044f\u0432\u0438\u0442, \u0447\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u0431\u044b\u043b\u044c \u043f\u043e\u0432\u043b\u0438\u044f\u043b\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434\u044b, \u043d\u043e \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0441\u0435\u0437\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0435\u043d \u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0432\u043f\u0430\u043b\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441 \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434\u0430\u043c\u0438 \u0438 \u043c\u043e\u0433\u043b\u0438 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0438\u043c\u044b\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434\u0430\u043c\u0438 \u0438 \u043f\u0440\u043e\u0446\u0435\u043d\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u0441\u0430\u043c\u043e\u043a\u0430\u0442\u043e\u0432 \u0432 \u0434\u043e\u043b\u0435 \u043f\u0440\u043e\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412\u0430\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0441 \u0447\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435. \u041e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043c\u0435\u0441\u044f\u0446, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u043b\u0435\u043d\u0434\u0430\u0440\u043d\u044b\u0439 \u043c\u0435\u0441\u044f\u0446 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0433\u043e\u0434\u0430 \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u0433\u0435\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c. \u041d\u043e \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0410\u0411 \u0442\u0435\u0441\u0442\u0430 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u043d\u0430 100% \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0445\u043e\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438? \u0415\u0441\u043b\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0439 \u0432\u0441\u0435\u0433\u043e 5-10, \u0438 \u043e\u043d\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0448\u0443\u043c\u043b\u0435\u043d\u044b, \u0442\u043e \u0441\u043c\u044b\u0441\u043b \u0432 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u043e\u043c &#8212; \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u2013 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e.<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430\u043c<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/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   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(n_samples: int) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=100, scale=10, size=n_samples \/\/ 2),             np.random.normal(loc=95, scale=10, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2) print(test_data.head())  sns.lineplot(x=\"time\", y=\"metric\", data=test_data) plt.show() <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0448\u0443\u043c\u043d\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 metric \u0437\u0430 \u0434\u0432\u0430 \u043c\u0435\u0441\u044f\u0446\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439.<\/figcaption><\/div>\n<\/figure>\n<p>\u041c\u0435\u0442\u0440\u0438\u043a\u0430 \u0448\u0443\u043c\u043d\u0430\u044f, \u0447\u0442\u043e \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0434\u0432\u0443\u0445 \u0442\u043e\u0447\u0435\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u043a\u0430\u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043e\u0431\u0449\u0435\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u043b\u043e \u043d\u0438\u0436\u0435. \u041a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c?<\/p>\n<h2>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/h2>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u043d\u0430\u0439\u0442\u0438 \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u043d\u0430 \u043f\u0440\u0435\u0434 \u043f\u0435\u0440\u0438\u043e\u0434\u0435, \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u043d\u0430 \u043f\u043e\u0441\u0442 \u043f\u0435\u0440\u0438\u043e\u0434\u0435 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>Python \u00a0\u043a\u043e\u0434<\/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   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(n_samples: int) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=100, scale=10, size=n_samples \/\/ 2),             np.random.normal(loc=95, scale=10, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2) print(test_data.head())   # \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u043d\u0430 \u043f\u0440\u0435\u0434\u043f\u0435\u0440\u0438\u043e\u0434\u0435 \u0438 \u043f\u043e\u0441\u0442\u043f\u0435\u0440\u0438\u043e\u0434\u0435 avg_1m = test_data.iloc[:ONE_MONTH].metric.mean() avg_2m = test_data.iloc[ONE_MONTH:].metric.mean()   sns.lineplot(x=\"time\", y=\"metric\", data=test_data) # \u0413\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043b\u0438\u043d\u0438\u0435\u0439 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0438 \u0432\u0442\u043e\u0440\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 plt.hlines(     y=avg_1m,     xmin=test_data.iloc[0].time,     xmax=test_data.iloc[ONE_MONTH - 1].time,     color=\"red\", )   plt.hlines(     y=avg_2m,     xmin=test_data.iloc[ONE_MONTH].time,     xmax=test_data.iloc[-1].time,     color=\"red\", )  plt.show() <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043b\u044f \u0434\u0432\u0443\u0445 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0447\u0435\u0440\u0435\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u0440\u0435\u0434\u043d\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0432\u0430 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0441\u043e\u0432\u043f\u0430\u0434\u0443\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0443\u043b\u0435\u0432\u0430\u044f. \u0412 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u0440\u0430\u0432\u0430\u044f \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437-\u0437\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u0439. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<h2>\u0422\u0435\u0441\u0442 \u0421\u0442\u044c\u044e\u0434\u0435\u043d\u0442\u0430<\/h2>\n<p>t-\u0442\u0435\u0441\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439. \u041f\u0440\u0438 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u0445\u0438-\u043a\u0432\u0430\u0434\u0440\u0430\u0442-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e,<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d<\/p>\n<\/li>\n<li>\n<p>\u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, QQ-plot, \u043b\u0438\u0431\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u0428\u0430\u043f\u0438\u0440\u043e-\u0412\u0438\u043b\u043a\u0430, \u041a\u043e\u043b\u043c\u043e\u0433\u043e\u0440\u043e\u0432\u0430-\u0421\u043c\u0438\u0440\u043d\u043e\u0432\u0430, \u0438 \u0434\u0440\u0443\u0433\u0438\u0445). \u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u043e, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/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   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(     n_samples: int, loc1: int = 100, scale1: int = 10, loc2: int = 99, scale2: int = 10 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=loc1, scale=scale1, size=n_samples \/\/ 2),             np.random.normal(loc=loc2, scale=scale2, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 test_data = generate_data(ONE_MONTH * 2) data_month1 = test_data.iloc[:ONE_MONTH].metric data_month2 = test_data.iloc[ONE_MONTH:].metric   # \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0442\u0435\u0441\u0442 \u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u0441\u044f\u0446\u0430 # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0434\u043b\u044f \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043e\u043a def sample_means(data, n_samples=100, n_iterations=1000):     means = np.zeros(n_iterations)     for i in range(n_iterations):         sample = np.random.choice(data, size=n_samples, replace=True)         means[i] = sample.mean()     return means   month_1_means = sample_means(data_month1) month_2_means = sample_means(data_month2)   if stats.shapiro(month_1_means).pvalue &lt; 0.05:     print(\"Month 1 means are not normally distributed. Can't use t-test\") if stats.shapiro(month_2_means).pvalue &lt; 0.05:     print(\"Month 2 means are not normally distributed. Can't use t-test\")  fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 5)) # QQ-\u0433\u0440\u0430\u0444\u0438\u043a \u0434\u043b\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u0435\u0441\u044f\u0446\u0435 stats.probplot(month_1_means, dist=\"norm\", plot=ax1)   # \u0442\u0435\u0441\u0442 \u043d\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 chi2 \u0441\u0440\u0435\u0434\u043d\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0437\u0430 1-\u0439 \u0438 2-\u0439 \u043c\u0435\u0441\u044f\u0446\u044b def sample_variances(data, n_iterations=1000):     variances = np.zeros(n_iterations)     for i in range(n_iterations):         sample = np.random.choice(data, size=len(data), replace=True)         variances[i] = sample.var()     return variances   # \u0433\u0440\u0430\u0444\u0438\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043e\u0447\u043d\u043e\u0439 \u0434\u0438\u0441\u043f\u0440\u0435\u0441\u0438\u0438 \u0437\u0430 \u043c\u0435\u0441\u044f\u0446 1 \u043f\u043e \u043e\u0441\u0438 ax2 month1_variances = sample_variances(data_month1) n1 = len(data_month1) sns.histplot(     month1_variances * (n1 - 1) \/ data_month1.var(),     stat=\"density\",     label=\"sample variance\",     ax=ax2, )  # \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f chi2 \u0441 n1-1 \u0441\u0442\u0435\u043f\u0435\u043d\u044f\u043c\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u044b \u043d\u0430 ax2 x = np.linspace(500, 1000, 1000) ax2.plot(x, stats.chi2.pdf(x, n1 - 1), color=\"red\", linewidth=2, alpha=0.5) ax2.set_xlabel(\"Sample variance\") ax2.set_ylabel(\"Density\") plt.show()  print(f\"p-value: {stats.ttest_ind(month_1_means, month_2_means).pvalue:.3f}\") <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\">\n<div><figcaption>\u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 t-test<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u043d\u0430\u0447\u0438\u043c\u044b.<\/p>\n<h2>\u0422\u0435\u0441\u0442 \u041c\u0430\u043d\u043d\u0430-\u0423\u0438\u0442\u043d\u0438<\/h2>\n<p>\u041c\u0430\u043d\u0430-\u0423\u0438\u0442\u043d\u0438, U-test. \u042d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0438\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"https:\/\/habr.com\/ru\/companies\/avito\/articles\/709596\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f 1000 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u0432\u0443\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0438 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>Python \u043a\u043e\u0434<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import scipy.stats as stats   # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 def generate_data(     n_samples: int, loc1: int = 100, scale1: int = 10, loc2: int = 99, scale2: int = 10 ) -> pd.DataFrame:     time = pd.date_range(\"2024-01-01\", periods=n_samples, freq=\"1H\")     data = np.concatenate(         (             np.random.normal(loc=loc1, scale=scale1, size=n_samples \/\/ 2),             np.random.normal(loc=loc2, scale=scale2, size=n_samples - n_samples \/\/ 2),         )     )     return pd.DataFrame({\"time\": time, \"metric\": data})   ONE_MONTH = 24 * 30 log_false_positives_t = [] log_false_positives_u = [] for _ in range(1000):     test_data = generate_data(ONE_MONTH * 2, loc1=100, loc2=100, scale1=10, scale2=100)      data_month1 = test_data.iloc[:ONE_MONTH].metric     data_month2 = test_data.iloc[ONE_MONTH:].metric      u_test_results = stats.mannwhitneyu(data_month1, data_month2)     t_test_results = stats.ttest_ind(data_month1, data_month2)      log_false_positives_t.append(t_test_results.pvalue &lt; 0.05)     log_false_positives_u.append(u_test_results.pvalue &lt; 0.05)  print(f\"False positives for t-test: {np.mean(log_false_positives_t):.3f}\") print(f\"False positives for U-test: {np.mean(log_false_positives_u):.3f}\") <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>U-test \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u044b\u0434\u0430\u0451\u0442 \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0439 (\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435<\/p>\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-365561","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/365561","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=365561"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/365561\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=365561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=365561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=365561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}