{"id":338560,"date":"2022-09-21T03:00:13","date_gmt":"2022-09-21T03:00:13","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=338560"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=338560","title":{"rendered":"<span>\u041a\u0442\u043e \u0436\u0435 \u0442\u0430\u043a\u043e\u0439 \u044d\u0442\u043e\u0442 \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u0438\u0439 \u0431\u0430\u043d\u0434\u0438\u0442?<\/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<h2>1. \u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0447\u0442\u043e \u0432\u044b \u043e\u0447\u0435\u043d\u044c \u0430\u0437\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u0433\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u043b \u0432 \u043a\u0430\u0437\u0438\u043d\u043e \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u0437\u0430 \u043a\u0430\u043a\u043e\u0439 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442 \u0435\u043c\u0443 \u0441\u0435\u0441\u0442\u044c. \u0418\u043b\u0438 \u043e\u0434\u0438\u043d \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0438\u0437 \u043a\u043e\u043b\u043e\u043d\u0438\u0438, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0449\u0438\u0439 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0435\u043c\u0443 \u043f\u043e\u0439\u0442\u0438 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a\u0438 \u043f\u0438\u0449\u0438. \u0418\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432\u044b \u2013 \u044d\u0442\u043e \u0446\u0435\u043b\u044b\u0439 \u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0443\u043c\u0430\u0435\u0442, \u043a\u0430\u043a\u0443\u044e \u0436\u0435 \u0446\u0435\u043d\u0443, \u0435\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0442\u043e\u0432\u0430\u0440! <\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b. \u041d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0415\u0441\u043b\u0438 \u043e\u0442\u043a\u0438\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0434\u0438\u043b\u0435\u043c\u043c\u0430 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f-\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0430\u043c\u0438: \u043a\u0430\u043a \u0430\u0437\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u0433\u0440\u043e\u043a, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442, \u0434\u0430\u044e\u0449\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u043d\u0435\u0433 \u2013 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u043e \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442 \u0438 \u0438\u0449\u0438\u0442\u0435 \u0435\u0433\u043e, \u0434\u0435\u0440\u0433\u0430\u044f \u0440\u0443\u0447\u043a\u0438 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0438 \u2013 \u044d\u0442\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435. \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0438\u0433\u0440\u043e\u0432\u043e\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u0438\u0431\u044b\u043b\u044c\u043d\u044b\u0439, \u0430 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435? \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u044e \u043d\u0443\u0436\u043d\u043e \u0438\u0434\u0442\u0438 \u043f\u043e \u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0433\u0434\u0435 \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0438-\u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u0443\u0436\u0435 \u043f\u0440\u043e\u0442\u043e\u043f\u0442\u0430\u043b\u0438 \u0442\u0440\u043e\u043f\u0438\u043d\u043a\u0443, \u0430 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0440\u0438\u0441\u043a\u043d\u0443\u0442\u044c \u0438 \u043f\u043e\u0439\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u0434\u043e\u0440\u043e\u0433\u043e\u0439? \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0446\u0435\u043d\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043f\u0435\u0432\u0430\u0442\u044c \u0437\u0430 \u0438\u043d\u0444\u043b\u044f\u0446\u0438\u0435\u0439 \u0438 \u0441\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0430 \u0435\u0449\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0431\u044b\u043b\u044c?<\/p>\n<p>\u041e\u0442\u043a\u0438\u043d\u0435\u043c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043c\u043e\u0440\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438 \u0441\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"E\\left[R\\left(a\\right)\\right]\\rightarrow \\max_a  \\\\a\\ \\in \\{ a_1,a_2,\\ldots,\\ a_n \\}\" alt=\"E\\left[R\\left(a\\right)\\right]\\rightarrow \\max_a  \\\\a\\ \\in \\{ a_1,a_2,\\ldots,\\ a_n \\}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad2\/06e\/484\/ad206e484c8349b6effc1ae763a0756c.svg\" width=\"697\" height=\"59\"\/><\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435: \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 (\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u044b \u0432 \u043a\u0430\u0437\u0438\u043d\u043e, \u043e\u0431\u044a\u0435\u043c\u044b \u043f\u0440\u043e\u0434\u0430\u0436), \u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435. \u042d\u0442\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 <em>a<\/em> \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 <em>{a<sub>1<\/sub>, a<sub>2<\/sub>, \u2026, a<sub>n<\/sub>}<\/em>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0443\u0447\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u043d\u044b\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437 \u0434\u0430\u0432\u0430\u043b\u043e \u0431\u044b \u043d\u0430\u043c \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0431\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u044b\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0431\u044b \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0436\u0438\u0442\u044c \u0432 \u0442\u043e\u0439, \u0433\u0434\u0435 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0438\u0433\u0440\u0430\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e! \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430, \u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0437\u0430 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u0441\u0440\u043e\u043a. \u0422\u043e \u0435\u0441\u0442\u044c, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u044b \u043f\u043e\u0439\u043c\u0435\u043c \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u0435\u0440\u043d\u043e\u0435, \u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u00ab\u043d\u0430 \u0440\u0443\u043a\u0430\u0445\u00bb \u0441\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u044b\u0442\u043e\u043a, \u0438\u043b\u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u043b\u0438 \u043d\u0435 \u00ab\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435\u00bb \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043c\u0435\u0442\u0440\u0438\u043a\u0438,<\/em> \u0438 \u043e \u043d\u0438\u0445 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0439 (\u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e\u0439) \u0437\u0430\u0434\u0430\u0447\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u044b\u0440\u043d\u0443\u0442\u044c \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438!<\/p>\n<h2>2. \u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043b\u0443\u0447\u0448\u0435?<\/h2>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0411\u043e\u043b\u044c\u0448\u0435 \u0442\u043e\u0433\u043e \u2013 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0435 \u043d\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b! <\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f 4 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"{w_{opt}}_t=\\begin{cases}1,{\u0435\u0441\u043b\u0438\\ \u043c\u044b\\ \u0432\u044b\u0431\u0440\u0430\u043b\u0438\\ \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435\\ \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435} \\\\ 0  \\end{cases}\" alt=\"{w_{opt}}_t=\\begin{cases}1,{\u0435\u0441\u043b\u0438\\ \u043c\u044b\\ \u0432\u044b\u0431\u0440\u0430\u043b\u0438\\ \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435\\ \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435} \\\\ 0  \\end{cases}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/062\/e68\/6c3\/062e686c3f3e2279c52755dd8b433511.svg\" width=\"391\" height=\"49\"\/><\/p>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u0443\u044e \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0438\u043b\u0438 \u043d\u043e\u043b\u0438\u043a \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438. \u041d\u043e \u044d\u0442\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u0440\u0435\u0434\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b (\u0441\u043f\u043e\u0439\u043b\u0435\u0440: \u0442\u0430\u043a \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c). \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0443\u0447\u043a\u0438, \u00ab\u043e\u0442\u0447\u0438\u0449\u0435\u043d\u043d\u0443\u044e\u00bb \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e! <\/p>\n<p>\u041d\u043e \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u0436\u0438\u0432\u0435\u043c \u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043d\u043e\u0433\u043e-\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 \u043d\u0443\u043b\u044f (\u0434\u0430 \u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u0448\u0435 \u0431\u043b\u0430\u0433\u043e\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u0430\u0437\u0438\u043d\u043e). \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0435\u0449\u0435 \u0442\u0440\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041e\u043d\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0442\u043e\u0436\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438 \u0438, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0445 \u0443\u0441\u0440\u0435\u0434\u043d\u0438\u043c, \u0431\u0443\u0434\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0430\u0434\u043a\u0438\u043c\u0438 \u0438 \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u043c\u0438 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u00ab\u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u00bb, \u043d\u043e \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u043c \u043e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0432\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0435\u0441\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u2014 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"{r\\_avg}_t=\\ \\frac{\\sum_{i=1}^{t}R_i}{t}\\ \" alt=\"{r\\_avg}_t=\\ \\frac{\\sum_{i=1}^{t}R_i}{t}\\ \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/23f\/d2d\/8d7\/23fd2d8d76de459dd9bca8945d5a800a.svg\" width=\"165\" height=\"49\"\/><\/p>\n<p>\u0418 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435:   <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"{r\\_total}_t=\\ \\sum_{i=1}^{t}R_i\\ \" alt=\"{r\\_total}_t=\\ \\sum_{i=1}^{t}R_i\\ \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/098\/cc6\/b33\/098cc6b33ac52f80a28d624ee518ca8a.svg\" width=\"155\" height=\"59\"\/><\/p>\n<p>R<em>\u00ad<sub>i<\/sub><\/em> \u2013 \u044d\u0442\u043e \u043d\u0430\u0433\u0440\u0430\u0434\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0437\u0430 <em>i<\/em>-\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. <\/p>\n<p>\u0421 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438 \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430 \u043e\u0434\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 (\u0438 \u0447\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0441\u0442\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u2013 \u0442\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0441 \u043b\u0443\u0447\u0448\u0435). \u0410 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0438 \u0447\u0435\u043c \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u2013 \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435). <\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f, \u043d\u043e \u043d\u0435 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043f\u043e\u0442\u0435\u0440\u044c (\u0438\u043d\u043e\u0433\u0434\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <em>regret<\/em> \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u0435): <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"reg_t=\\ \\sum_{i=1}^{t}{R_{opt}-R_t}\\ \" alt=\"reg_t=\\ \\sum_{i=1}^{t}{R_{opt}-R_t}\\ \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/911\/408\/d29\/911408d2990a5c27597aa9503319074b.svg\" width=\"183\" height=\"59\"\/><\/p>\n<p>R<sub>opt<\/sub> \u2013 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438, \u0435\u0441\u043b\u0438 \u0431\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c. \u0414\u0430\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435. \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u0435\u0442\u0440\u0438\u043a\u0443, \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0438 \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a\u0430\u044f \u0440\u0443\u0447\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0430 \u0434\u0430\u0435\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c. \u041d\u043e \u0447\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u043c? \u041e\u0431\u044b\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043a\u0430\u043a\u0443\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 \u043c\u044b \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041e\u0442\u043c\u0435\u0447\u0443 \u0442\u0430\u043a \u0436\u0435, \u0447\u0442\u043e \u044d\u0442\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043d\u0435 \u0442\u0430\u043a \u0436\u0435\u0441\u0442\u043e\u043a\u0430, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u043a \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443, \u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u043c\u0443 \u043a \u043d\u0435\u043c\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0435\u0435\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u0435\u0440\u044c, \u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u043f\u0435\u0440\u0432\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430)<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0446\u0435\u043b\u044b\u0445 4 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0438 \u0441\u0430\u043c\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b!<\/p>\n<h2>3. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/h2>\n<p>\u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0444\u0440\u0430\u0437\u0430: \u00ab\u041f\u043e\u043a\u0430 \u0442\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043a\u043e\u0434\u0435 \u2013 \u0442\u044b \u043d\u0435 \u043f\u043e\u043d\u044f\u043b \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u00bb. \u0422\u0430\u043a \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435!<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0437\u0430\u0434\u0430\u0434\u0438\u043c environment (\u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u0443), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442 \u043d\u0430\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0438 \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u043d\u0430 \u043a\u0430\u0437\u0438\u043d\u043e \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f). \u041d\u043e \u0442\u0430\u043a\u0430\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0438\u0437-\u0437\u0430 \u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. <\/p>\n<pre><code class=\"python\">import numpy as np  class BanditEnv():   def __init__(self, probs, reward):     self.probs = probs     self.reward = reward     self._optimal_action = np.argmax(list(map(lambda x,y: x*y, probs, reward)))     self._optimal_reward = np.max(list(map(lambda x,y: x*y, probs, reward)))    def step(self, action):     return self.reward[action] if np.random.rand(1).item() &lt; self.probs[action] else 0  env = BanditEnv([0.3, 0.2, 0.1, 0.2, 0.9], [1, 1, 1, 1, 2])<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0448\u0430 \u0441\u0440\u0435\u0434\u0430 env \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 BanditEnv \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443 \u043d\u0430\u0441 5 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 0.3 \u043f\u0435\u0440\u0432\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443 1, \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 0.2 \u0432\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443 1 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u044f\u0442\u043e\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u043d\u0430\u0433\u0440\u0430\u0434\u0443 1.8.   <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 (\u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0435\u043b\u0435\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438). \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <em>\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/em>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u044b (<em>__init__, update, reset<\/em>), \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0440\u0430\u0437 \u0437\u0430 \u0440\u0430\u0437\u043e\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 <em>abstractmethod<\/em> \u043c\u044b \u043e\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043f\u043e\u0434 \u0442\u0435\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. <\/p>\n<pre><code class=\"python\">from abc import ABC, abstractmethod  class Strategy(ABC):   def __init__(self, n_arms, epsilon):     self.Q = np.zeros(n_arms)     self.n = [0 for _ in range(n_arms)]     self.epsilon = epsilon     self.n_arms = n_arms        @abstractmethod   def make_action(self):     pass        def update(self, action, reward):     self.n[action] += 1     self.Q[action] = (self.Q[action] * (self.n[action]-1) + reward)\/self.n[action]            def reset(self):     self.__init__(self.n_arms, self.epsilon)<\/code><\/pre>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 \u0437\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 Q, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 n, \u0430 epsilon \u2013 \u044d\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0432\u043e\u0439 \u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435. \u041c\u0435\u0442\u043e\u0434 update \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0430 \u043c\u0435\u0442\u043e\u0434 reset \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0441\u0440\u0435\u0434\u0435, \u0434\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0443\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e\u0442 \u044d\u043f\u0438\u0437\u043e\u0434\u044b, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0438 \u0440\u0438\u0441\u0443\u044e\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u0435\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from tqdm import tqdm import matplotlib.pyplot as plt  def run_n_episodes(env, strategy, n_episodes):   w_opt_stat, r_avg_stat, r_total_stat, reg_stat = [],[],[],[]   w_opt_times, total_reward, reg = 0, 0, 0   for episode in range(1, n_episodes+1):     action = strategy.make_action()     reward = env.step(action)     strategy.update(action, reward)     w_opt_stat.append(1 if action==env._optimal_action else 0)     total_reward += reward     r_total_stat.append(total_reward)     r_avg_stat.append(total_reward\/episode)     reg += env._optimal_reward - reward     reg_stat.append(reg)   return w_opt_stat, r_avg_stat, r_total_stat, reg_stat  def run_n_times(n_repeat, env, n_episodes, strategy):   w_opt_stat_full, r_avg_stat_full = [],[]   r_total_stat_full, reg_stat_full = [],[]   for _ in tqdm(range(n_repeat)):     strategy.reset()     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_episodes(env,                                                                      strategy,                                                                     n_episodes)     w_opt_stat_full.append(w_opt_stat)     r_avg_stat_full.append(r_avg_stat)     r_total_stat_full.append(r_total_stat)     reg_stat_full.append(reg_stat)   return np.array(w_opt_stat_full).mean(axis=0), np.array(r_avg_stat_full).mean(axis=0),\\        np.array(r_total_stat_full).mean(axis=0), np.array(reg_stat_full).mean(axis=0)  def plot_stats(w_opt_stat, r_avg_stat, r_total_stat, reg_stat, legends = False):     plt.figure(figsize=(12, 7))     plt.subplot(2, 2, 1)     for i in w_opt_stat:         plt.plot(i)     plt.xlabel('t')     plt.ylabel('w_opt')     if legends: plt.legend(legends)     plt.subplot(2, 2, 2)     for i in r_avg_stat:         plt.plot(i)     plt.xlabel('t')     plt.ylabel('r_avg')     if legends: plt.legend(legends)     plt.subplot(2, 2, 3)     for i in r_total_stat:         plt.plot(i)     plt.xlabel('t')     plt.ylabel('r_total')     if legends: plt.legend(legends)     plt.subplot(2, 2, 4)     for i in reg_stat:         plt.plot(i)     plt.xlabel('t')     plt.ylabel('reg')     if legends: plt.legend(legends)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>4. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0437\u0443\u0447\u0438\u043c, \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c<\/h2>\n<p>\u041f\u0435\u0440\u0432\u043e\u0439 \u0438\u0434\u0435\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u2013 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u043c \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u043f\u0440\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0438\u0433\u0440\u043e\u0432\u044b\u043c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0430\u043c), \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u043e\u0439 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0434\u0430\u0435\u0442 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 \u0438 \u043f\u043e\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043d\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0430\u044f! <\/p>\n<p>\u0418 \u0437\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 &#8212; \u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f? \u041d\u0443 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u044b\u0442\u043e\u043a. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 50 \u0440\u0430\u0437 \u0431\u0443\u0434\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f!<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0432\u044b\u0435 epsilon \u0440\u0430\u0437 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430\u043c \u0434\u0430\u0432\u0430\u043b\u043e \u043b\u0443\u0447\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u0441\u044f \u043e\u0442 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Strategy, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043b\u0438\u0448\u043d\u0438\u0439 \u0440\u0430\u0437 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c, \u043a\u0430\u043a \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <\/p>\n<pre><code class=\"python\">class Random\u0421hoiceStrategy(Strategy):          def make_action(self):         if sum(self.n) &lt; self.epsilon:             return np.random.randint(self.n_arms)         return np.argmax(self.Q)<\/code><\/pre>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(100, env, 250, Random\u0421hoiceStrategy(5, 50)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u2013 \u0434\u043e 50 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f 20% \u0438\u043b\u0438 1 \u0440\u0430\u0437 \u0438\u0437 5. \u041d\u043e \u043f\u043e\u0442\u043e\u043c \u043c\u044b \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u043a\u0430\u043a\u043e\u0435 \u0436\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435. \u041d\u0430\u0448\u0430 \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u043f\u043e\u0441\u043b\u0435 50-\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0441\u0442\u0438, \u0430 \u043f\u043e\u0442\u0435\u0440\u0438 \u0434\u043e 50-\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0440\u0430\u0441\u0442\u0435\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bc2\/a4d\/5d7\/bc2a4d5d782a8ceb64241a8c0683ebf9.png\" alt=\"Random Choice Strategy\" title=\"Random Choice Strategy\" width=\"724\" height=\"429\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bc2\/a4d\/5d7\/bc2a4d5d782a8ceb64241a8c0683ebf9.png\"\/><figcaption>Random Choice Strategy<\/figcaption><\/figure>\n<p>\u041d\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c 50 \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0430\u0437\u043d\u044b\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full = [],[],[],[] epsilons = [5, 10, 20, 30, 50] for epsilon in epsilons:   w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(500, env, 250, Random\u0421hoiceStrategy(5, epsilon))   for f, l in zip([w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full],                   [w_opt_stat, r_avg_stat, r_total_stat, reg_stat]):     f.append(l) plot_stats(w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full, epsilons)<\/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\/965\/207\/348\/965207348bcf6dd0a58e9acb2722df00.png\" alt=\"Random Choice Strategy parameters \" title=\"Random Choice Strategy parameters \" width=\"724\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/965\/207\/348\/965207348bcf6dd0a58e9acb2722df00.png\"\/><figcaption>Random Choice Strategy parameters <\/figcaption><\/figure>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e 5 \u0438 10 \u2014 \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0435 \u0436\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435. 20 \u0440\u0430\u0437 \u0442\u043e\u0436\u0435 \u043d\u0435 \u0434\u043e\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u0442 \u0434\u043e \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0434\u043e 1, \u0437\u0430\u0442\u043e 30 \u0438 50 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c\u0438. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, 20 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0442\u0435\u0440\u044c \u043f\u043e\u0441\u043b\u0435 250 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.\u00a0 \u0421 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0442\u0438. \u0412 \u0442\u0435\u043e\u0440\u0438\u0438, \u0437\u043d\u0430\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0433\u0440\u0430\u0434 \u0437\u0430 \u044d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u042d\u0442\u043e \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 A\/B, A\/B\/C \u0438 \u0442\u0434. \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u041d\u043e \u043d\u0430\u0448\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043d\u0438\u0447\u0435\u0433\u043e \u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u0430\u0433\u0440\u0430\u0434 \u0437\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u2013 \u043f\u0443\u0441\u0442\u044c \u043e\u043d \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u043d\u0430\u0433\u0440\u0430\u0434\u0430\u0445, \u0430 \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043d\u0430 \u0442\u0430\u043a\u043e\u0439 \u0438\u0434\u0435\u0435 \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0438 \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0434\u0430\u043b\u044c\u0448\u0435!<\/p>\n<h2>5. \u0416\u0430\u0434\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u043f\u043e\u0440\u043e\u043a<\/h2>\n<p>\u0415\u0449\u0435 \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438\u0434\u0435\u0439 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u2013 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0436\u0430\u0434\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c. \u041d\u0443 \u0430 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u2013 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0440\u0443\u0447\u043a\u0443, \u0432\u0434\u0440\u0443\u0433 \u043e\u043d\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043b\u0443\u0447\u0448\u0435! \u042d\u0442\u0430 \u0438\u0434\u0435\u044f \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0430 \u0432 \u044d\u043f\u0441\u0438\u043b\u043e\u043d-\u0436\u0430\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u0412 \u0432\u0438\u0434\u0435 \u043a\u043e\u0434\u0430 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a: <\/p>\n<pre><code class=\"python\">class EpsilonGreedyStrategy(Strategy):          def make_action(self):         if np.random.random() > self.epsilon:             return np.argmax(self.Q)         return np.random.randint(self.n_arms)<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441 \u044d\u043f\u0441\u0438\u043b\u043e\u043d \u0440\u0430\u0432\u043d\u044b\u043c 0.1. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 10% \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0430 \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c! <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(1000, env, 250, EpsilonGreedyStrategy(5, 0.1)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/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\/1f1\/f33\/adb\/1f1f33adb8186ea43a3ceb7bc78f738e.png\" alt=\"Epsilon Greedy Strategy\" title=\"Epsilon Greedy Strategy\" width=\"724\" height=\"429\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1f1\/f33\/adb\/1f1f33adb8186ea43a3ceb7bc78f738e.png\"\/><figcaption>Epsilon Greedy Strategy<\/figcaption><\/figure>\n<p>\u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u044b \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u0435\u043c\u0441\u044f \u043a \u043e\u0442\u043c\u0435\u0442\u043a\u0435 0.9. \u0418 \u044d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u2013 \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0443\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443 \u0438 \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435, \u043e\u043d \u0432 90% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0435\u0433\u043e. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0447\u0443\u0442\u044c \u0445\u0443\u0436\u0435, \u0447\u0435\u043c \u0443 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u041d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u044d\u043f\u0441\u0438\u043b\u043e\u043d<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full = [],[],[],[] epsilons = [0.1, 0.2, 0.3, 0.5] for epsilon in epsilons:   w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(500, env, 250, EpsilonGreedyStrategy(5, epsilon))   for f, l in zip([w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full],                   [w_opt_stat, r_avg_stat, r_total_stat, reg_stat]):     f.append(l) plot_stats(w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full, epsilons)<\/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\/357\/fb3\/b51\/357fb3b51d1864dd55be016e8e958a8d.png\" alt=\"Epsilon Greedy Strategy parameters\" title=\"Epsilon Greedy Strategy parameters\" width=\"724\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/357\/fb3\/b51\/357fb3b51d1864dd55be016e8e958a8d.png\"\/><figcaption>Epsilon Greedy Strategy parameters<\/figcaption><\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0443\u0447\u043a\u0438 \u0441\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043a 1 -\u044d\u043f\u0441\u0438\u043b\u043e\u043d. \u0422\u043e \u0435\u0441\u0442\u044c \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u044d\u0442\u043e \u043f\u043b\u043e\u0445\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0442\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u0433\u0440\u0430\u0434\u0443, \u0430 \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0432\u0434\u0440\u0443\u0433 \u0432 \u043c\u0438\u0440\u0435 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u043e\u0441\u044c \u0438 \u043d\u0430\u0448\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u043e \u0431\u044b\u0442\u044c \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0439\u0442\u0438 \u043d\u043e\u0432\u043e\u0435 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0435\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0420\u0435\u043d\u0435 \u0414\u0435\u043a\u0430\u0440\u0442: <em>\u00ab\u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0443\u0436\u043d\u043e \u0432\u043e \u0432\u0441\u0451\u043c, \u043a\u0440\u043e\u043c\u0435\u00a0\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f\u00bb<\/em>. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0441\u0443\u0434\u0438\u0442\u044c \u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0435 \u043f\u043e\u0442\u0435\u0440\u044c \u2013 \u0442\u043e \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u044d\u043f\u0441\u0438\u043b\u043e\u043d \u0440\u0430\u0432\u043d\u044b\u0439 0.2 \u2013 \u043a \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 250 \u043e\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u0434\u0435-\u0442\u043e \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 75, \u0447\u0442\u043e \u0443\u0436\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u043e \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439!<\/p>\n<h2>6. \u041c\u044f\u0433\u043a\u0438\u0439 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c<\/h2>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0443 \u044d\u043f\u0441\u0438\u043b\u043e\u043d-\u0436\u0430\u0434\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u0441\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0443\u043c\u0430\u0435\u043c, \u043a\u0430\u043a\u043e\u0435 \u0436\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0430\u043c \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043d\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u043f\u043e\u0441\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u0418\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0438 \u043d\u0435\u0434\u043e\u0447\u0435\u0442\u044b \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u2013 <em>softmax<\/em> \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b. \u041e\u043d\u0438 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 softmax, \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0439 \u043c\u043d\u043e\u0433\u0438\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0432\u0435\u043a\u0442\u043e\u0440 \u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u043d\u0430 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"softmax\\left(x\\right)_i=\\ \\frac{e^{x_i}}{\\sum_{k=1}^{K}e^{x_k}}\\ \" alt=\"softmax\\left(x\\right)_i=\\ \\frac{e^{x_i}}{\\sum_{k=1}^{K}e^{x_k}}\\ \" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9b9\/72c\/284\/9b972c284d7f2f113fc8ce65bc32d58d.svg\" width=\"224\" height=\"53\"\/><\/p>\n<p>\u0415\u0435 \u0441\u043c\u044b\u0441\u043b \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043b\u044e\u0431\u043e\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u043a \u0432\u0435\u043a\u0442\u043e\u0440\u0443 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u0435\u043c\u0443 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u0447\u0438\u0441\u043b\u0430\u043c\u0438, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u044b\u0432 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u043c\u0438. \u042d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u043c\u043d\u043e\u0436\u0430\u044f \u0438\u043b\u0438 \u0434\u0435\u043b\u044f \u0432\u0435\u0441\u044c \u0432\u0435\u043a\u0442\u043e\u0440 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0439 \u0438\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0440\u0430\u0437\u0440\u044b\u0432 \u0432 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044f\u0445. \u0410 \u0443\u0436\u0435 \u044d\u0442\u0438 \u0441\u0430\u043c\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438. \u041a\u043e\u0434 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def softmax(x):   return np.exp(x)\/np.sum(np.exp(x))  class SoftMaxStrategy(Strategy):   def make_action(self):     probs = softmax(self.Q\/self.epsilon)     return np.random.choice(self.n_arms, p=probs)<\/code><\/pre>\n<p>\u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e softmax, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0439 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043e\u043d\u0438 \u043d\u0430\u043c \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u043b\u0438. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(200, env, 250, SoftMaxStrategy(5, 0.1)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/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\/eef\/48d\/e02\/eef48de0269bf2304dd7baf93182be98.png\" alt=\"Soft Max Strategy\" title=\"Soft Max Strategy\" width=\"724\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eef\/48d\/e02\/eef48de0269bf2304dd7baf93182be98.png\"\/><figcaption>Soft Max Strategy<\/figcaption><\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043b\u0443\u0447\u0448\u0435 \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b! \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0443\u0447\u043a\u0438 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u044c\u0441\u044f \u043a \u0435\u0434\u0438\u043d\u0438\u0446\u0435, \u0430 \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 30! \u041d\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full = [],[],[],[] thetas = [0.1, 0.2, 0.3, 0.5] for theta in thetas:   w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(100, env, 250, SoftMaxStrategy(5, theta))   for f, l in zip([w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full],                   [w_opt_stat, r_avg_stat, r_total_stat, reg_stat]):     f.append(l) plot_stats(w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full, thetas)<\/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\/a09\/b00\/f44\/a09b00f44bef1e91239c46d646d53d59.png\" alt=\"Soft Max Strategy parameters\" title=\"Soft Max Strategy parameters\" width=\"724\" height=\"428\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a09\/b00\/f44\/a09b00f44bef1e91239c46d646d53d59.png\"\/><figcaption>Soft Max Strategy parameters<\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b 0.2 \u0438 0.3. \u041e\u043d\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u043e\u0445\u043e\u0436\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043a\u0430\u043a \u0432 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0443\u0447\u043a\u0438, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043f\u043e\u0442\u0435\u0440\u044c. <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u00ab\u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043e\u0442\u0436\u0438\u0433\u0430\u00bb. \u042d\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u0438\u0437 \u0444\u0438\u0437\u0438\u043a\u0438, \u0433\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e softmax (\u043f\u0440\u0430\u0432\u0434\u0430 \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0433\u043e\u0440\u0435\u043d\u0438\u044f \u0438 \u043d\u0430\u0433\u0440\u0435\u0432\u0430\u043d\u0438\u044f. \u0422\u0430\u043a \u0432\u043e\u0442, \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u0435\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043d\u0438\u0436\u0430\u0442\u044c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0443\u0436\u0435 \u0438 \u0442\u0430\u043a \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u0437\u043d\u0430\u0435\u043c! \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">class AnnealingSoftMaxStrategy(Strategy):     def make_action(self):         theta = 1\/np.log(np.sum(self.n)+2)         probs = softmax(self.Q\/theta)         return np.random.choice(self.n_arms, p=probs)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(300, env, 250, AnnealingSoftMaxStrategy(5, 0)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/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\/bac\/2a2\/2d7\/bac2a22d7178b9bc384090188380719b.png\" alt=\"Annealing Soft Max Strategy\" title=\"Annealing Soft Max Strategy\" width=\"724\" height=\"428\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bac\/2a2\/2d7\/bac2a22d7178b9bc384090188380719b.png\"\/><figcaption>Annealing Soft Max Strategy<\/figcaption><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043d\u0430 \u043b\u0438\u0446\u043e \u2013 \u043c\u044b \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u043a \u0447\u0435\u043c\u0443 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438! \u0418 \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0431\u043e\u043d\u0443\u0441 \u2013 \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0431\u0440\u0430\u0442\u044c!<\/p>\n<h2>7. \u0414\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b<\/h2>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u043d\u0430\u0448\u0435\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0435\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0410 \u0435\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043d\u0435\u0435, \u0442\u043e \u0434\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043f\u043e\u0442\u0435\u0440\u044c \u0440\u0430\u0441\u0442\u0435\u0442 \u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u041e(log(t)). \u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0438 \u0432\u044b\u0432\u043e\u0434\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0441\u043e\u0431\u043e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u043e\u0442\u0441\u044b\u043b\u0430\u044e \u043a \u0431\u043e\u043b\u0435\u0435 \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438 \u043b\u0443\u0447\u0448\u0435 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c. <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u2013 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438\u043b\u0438 UCB \u043f\u043e \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u0438\u0439. \u0415\u0433\u043e \u0441\u0443\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0435: <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"UCB_i=q_i\\ + \\sqrt{c *\\ \\frac{\\log{t}}{n_i} }\" alt=\"UCB_i=q_i\\ + \\sqrt{c *\\ \\frac{\\log{t}}{n_i} }\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/bb9\/691\/dd3\/bb9691dd34eb596c6b5be557899b455f.svg\" width=\"212\" height=\"62\"\/><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u0435: <\/p>\n<p>q \u2013 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <em>i<\/em>-\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/p>\n<p>c \u2013 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0448\u0438\u0440\u0438\u043d\u0443 \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0437\u0430 \u0442\u043e, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043c\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f<\/p>\n<p>t \u2013 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f <\/p>\n<p>n<sub>i<\/sub> \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <em>i<\/em>-\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. <\/p>\n<p>\u041b\u043e\u0433\u0438\u043a\u0430 \u0442\u0430\u043a\u0430\u044f \u2013 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 (\u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c), \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b. \u041c\u044b \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0437\u043d\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 \u0437\u0430 \u0434\u0430\u043d\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u2013 \u0432\u0435\u0440\u0445\u043d\u044f\u044f \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f. \u0412 \u044d\u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c, \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0440\u0430\u0441\u0442\u0435\u0442 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0440\u043e\u0441\u0442\u0430 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044f, \u043d\u043e \u0440\u0430\u0441\u0442\u0435\u0442 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c. \u0418 \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e, \u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u043c \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c, \u0443\u0436\u0435 \u043d\u0430\u043c \u0442\u0430\u043a\u0438\u043c \u0438 \u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u043d\u0430\u0441 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u044e\u0442 \u043c\u0435\u043d\u0435\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0418 \u0432\u0441\u0435 \u043f\u043e \u043d\u043e\u0432\u043e\u0439. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e. \u041a\u043e\u043b\u0435\u0441\u043e \u0421\u0430\u043d\u0441\u0430\u0440\u044b \u0434\u0430\u043b\u043e \u043e\u0431\u043e\u0440\u043e\u0442.\u00a0 \u0418 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0438 \u0440\u0435\u0448\u0430\u0435\u043c \u0434\u0438\u043b\u0435\u043c\u043c\u0443 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f-\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u043e\u0434 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: <\/p>\n<pre><code class=\"python\">class UBCStrategy(Strategy):          def make_action(self):         c = np.sqrt(self.epsilon * np.log(np.sum(self.n)+1)\/(np.array(self.n)+1))         upper_bounds = self.Q + c         return np.argmax(upper_bounds)<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(400, env, 250, UBC1Strategy(5, 2)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/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\/52a\/f15\/115\/52af15115aed054bc872e937fa67d285.png\" alt=\"UBC Strategy\" title=\"UBC Strategy\" width=\"724\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/52a\/f15\/115\/52af15115aed054bc872e937fa67d285.png\"\/><figcaption>UBC Strategy<\/figcaption><\/figure>\n<p>\u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u0445 \u043e\u0442\u0447\u0435\u0442\u043b\u0438\u0432\u043e \u0432\u0438\u0434\u043d\u043e, \u0432 \u043a\u0430\u043a\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u0440\u043e\u0441\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u0448\u0435\u043b \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e, \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0433\u0434\u0435-\u0442\u043e \u043c\u0435\u0436\u0434\u0443 50 \u0438 100 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u043e \u0434\u0430\u0436\u0435 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b! \u0410 \u0432\u043e\u0442 \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full = [],[],[],[] params = [1, 2, 3, 5] for param in params:     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(100, env, 250, UBC1Strategy(5, param))     for f, l in zip([w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full],                   [w_opt_stat, r_avg_stat, r_total_stat, reg_stat]):         f.append(l) plot_stats(w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full, params)<\/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\/733\/319\/277\/733319277c25ef4c963c5a10f846f64b.png\" alt=\"UBC Strategy parametrs\" title=\"UBC Strategy parametrs\" width=\"724\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/733\/319\/277\/733319277c25ef4c963c5a10f846f64b.png\"\/><figcaption>UBC Strategy parametrs<\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043b\u0443\u0447\u0448\u0438\u043c \u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 c \u0440\u0430\u0432\u043d\u044b\u0439 1. \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043f\u0438\u0448\u0443\u0442 <em>UCB1, UCB2<\/em> \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0418 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u043e\u043c \u0431\u0430\u043d\u0434\u0438\u0442\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0434\u0432\u0443\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u044b\u0445 \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445!<\/p>\n<h2>8. \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0435 \u0431\u0430\u043d\u0434\u0438\u0442\u044b<\/h2>\n<p>\u0412\u0442\u043e\u0440\u044b\u043c \u0447\u0430\u0441\u0442\u044b\u043c \u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u043e\u043c \u0431\u0430\u043d\u0434\u0438\u0442\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0422\u043e\u043c\u043f\u0441\u043e\u043d\u0430 \u0438 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u0434\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0430 \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435! \u041e\u043d \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0434\u043b\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435, \u043d\u043e \u0437\u0430\u0442\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0434\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u043e \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u043c \u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0430\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u0430\u0440\u0443 \u0430\u0431\u0437\u0430\u0446\u0435\u0432. \u00a0\u0421\u0430\u043c\u043e \u0441\u043e\u0431\u043e\u0439 \u0437\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0441\u0436\u0430\u0442\u044b\u0439 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440 \u043f\u0440\u043e \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u044a\u0435\u043c\u043d\u0443\u044e \u0442\u0435\u043c\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043e\u0442\u0441\u044b\u043b\u0430\u044e \u043a \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043d\u0438\u0433\u0430\u043c:<\/p>\n<ul>\n<li>\n<p>\u041a\u0443\u0440\u0442 \u0423\u0438\u043b\u043b. \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430: Star Wars, LEGO, \u0440\u0435\u0437\u0438\u043d\u043e\u0432\u044b\u0435 \u0443\u0442\u043e\u0447\u043a\u0438 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 &#8212; \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0441\u0432\u0430\u043b\u044c\u0434\u043e \u041c\u0430\u0440\u0442\u0438\u043d. \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0430 Python &#8212; \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<p> \u0412 \u043d\u0438\u0445 \u0434\u0430\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0438 \u0447\u0435\u043c \u043e\u043d\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439. <\/p>\n<p>\u041d\u043e \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0442\u0435\u043c\u0435. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c, \u043d\u0430 \u043a\u0430\u043a\u0438\u0445 \u0438\u0434\u0435\u044f\u0445 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u044d\u0442\u043e \u0442\u0435\u043e\u0440\u0435\u043c\u0430 \u0411\u0430\u0439\u0435\u0441\u0430:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"P\\left(H\\middle| D\\right)=\\ \\frac{P\\left(D\\middle| H\\right)\\ast P\\left(H\\right)}{P\\left(D\\right)}\" alt=\"P\\left(H\\middle| D\\right)=\\ \\frac{P\\left(D\\middle| H\\right)\\ast P\\left(H\\right)}{P\\left(D\\right)}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/21a\/743\/06a\/21a74306a270b827d78da6d9ab7f2f26.svg\" width=\"248\" height=\"50\"\/><\/p>\n<p>\u0411\u0443\u043a\u0432\u043e\u0439 H \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430, \u0431\u0443\u043a\u0432\u043e\u0439 D \u2013 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f. \u0421\u043b\u0435\u0432\u0430 \u043e\u0442 \u0437\u043d\u0430\u043a\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u0430 \u2013 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0432\u0435\u0440\u043d\u0430, \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438\u043b\u0438 \u043b\u0443\u0447\u0448\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0448\u0430 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0435 H (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u0430\u043a \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0432 \u0447\u0435\u043c-\u043b\u0438\u0431\u043e). \u0421\u043f\u0440\u0430\u0432\u0430 \u0432 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u0435 \u2013 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0438, \u0447\u0442\u043e \u043d\u0430\u0448\u0430 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430 \u0432\u0435\u0440\u043d\u0430\u044f \u0438 \u043d\u0430\u0448\u0430 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0435 \u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u0417\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c, \u0433\u0440\u0443\u0431\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0432 \u0442\u0430\u043a\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u044b\u043c \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u043c (\u0435\u0441\u043b\u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u0433\u043e, \u0442\u043e \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c \u044d\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438, \u043f\u0440\u0438 \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430\u0445). \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c P(H) \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u043f\u0440\u0438\u043e\u0440\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u2013 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u0443\u043c\u0430\u043b\u0438 \u0434\u043e \u043e\u043f\u044b\u0442\u0430, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c P(H|D) \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u2013 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u0443\u043c\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435 \u043e\u043f\u044b\u0442\u0430, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c P(D|H) \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435\u043c. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u0412\u0430\u043c \u043d\u0430 \u0434\u0435\u043d\u044c \u0440\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0430\u0440\u0438\u043b\u0438 \u043c\u043e\u043d\u0435\u0442\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043d\u043e \u0432\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u043d\u0430\u0435\u0442\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0430\u043c \u0435\u0435 \u043f\u043e\u0434\u0430\u0440\u0438\u043b \u2013 \u043e\u043d \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u044b\u0433\u0440\u0430\u0442\u044c \u0432\u0430\u0441! \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043e\u043d \u043f\u043e\u0434\u0430\u0440\u0438\u043b \u043d\u0435\u0447\u0435\u0441\u0442\u043d\u0443\u044e \u043c\u043e\u043d\u0435\u0442\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u0430\u0434\u0430\u0442\u044c \u043e\u0440\u043b\u043e\u043c \u0438 \u0432\u044b \u0440\u0435\u0448\u0430\u0435\u0442\u0435 \u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c! \u0414\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u043d\u0430\u0447\u0430\u043b\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0432\u044b \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0436\u0434\u0430\u0442\u044c \u2013 \u043c\u043e\u043d\u0435\u0442\u043a\u0430 \u043b\u0438\u0431\u043e \u0447\u0435\u0441\u0442\u043d\u0430\u044f \u0438 \u0434\u0430\u0435\u0442 \u043e\u0440\u043b\u043e\u0432 \u0432 50% \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043b\u0438\u0431\u043e \u043d\u0435\u0447\u0435\u0441\u0442\u043d\u0430\u044f \u0438 \u043e\u0440\u043b\u044b \u0432\u044b\u043f\u0430\u0434\u0430\u044e\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 90% \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u043d\u0435\u0442\u043a\u0430 \u0447\u0435\u0441\u0442\u043d\u0430\u044f \u0434\u043b\u044f \u0432\u0430\u0441 \u0440\u0430\u0432\u043d\u0430 50%. \u0418 \u0432\u043e\u0442 \u043f\u043e\u0441\u043b\u0435 5 \u0431\u0440\u043e\u0441\u043a\u043e\u0432 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c 5 \u043e\u0440\u043b\u043e\u0432 \u043f\u043e\u0434\u0440\u044f\u0434. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u2013 \u0432\u0430\u0441 \u0445\u043e\u0442\u044f\u0442 \u0440\u0430\u0437\u044b\u0433\u0440\u0430\u0442\u044c! \u041d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u043f\u0435\u0448\u0438\u0442\u044c \u0441 \u0432\u044b\u0432\u043e\u0434\u0430\u043c\u0438 \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u043e\u0439 \u0411\u0430\u0439\u0435\u0441\u0430. \u0410\u043f\u0440\u0438\u043e\u0440\u043d\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u0430 0.5,\u00a0\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u0430\u0434\u0435\u043d\u0438\u044f 5 \u043e\u0440\u043b\u043e\u0432 \u043f\u0440\u0438 \u0447\u0435\u0441\u0442\u043d\u043e\u0439 \u043c\u043e\u043d\u0435\u0442\u043a\u0435 \u0440\u0430\u0432\u043d\u0430 (0.5)<sup>5<\/sup> \u0442\u043e\u0433\u0434\u0430 \u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c \u0440\u0430\u0432\u0435\u043d (0.5)<sup>6<\/sup>. \u0417\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0432\u0435\u043d ((0.5)<sup>5<\/sup> + (0.9)<sup>5<\/sup>)*0.5 (\u0417\u0434\u0435\u0441\u044c \u044f \u043e\u0442\u0441\u044b\u043b\u0430\u044e \u0432\u0430\u0441 \u043a \u0443\u0447\u0435\u0431\u043d\u0438\u043a\u0430\u043c \u043f\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0438\u043b\u0438 \u043a\u043d\u0438\u0433\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u0440\u0430\u043d\u0435\u0435). \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u043d\u0435\u0442\u043a\u0430 \u0447\u0435\u0441\u0442\u043d\u0430\u044f \u0440\u0430\u0432\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 0,05 \u0438\u043b\u0438 5%.\u00a0 \u042d\u0442\u043e \u043d\u0430\u0448\u0430 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u0430\u044f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c, \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u043e\u043d\u0435\u0442\u043a\u0430 \u0447\u0435\u0441\u0442\u043d\u0430\u044f. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043d\u0430\u0441 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u044b\u0433\u0440\u0430\u0442\u044c, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0430 5% \u043c\u044b \u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448\u0435\u043c\u0443 \u0434\u0440\u0443\u0433\u0443. <\/p>\n<p>\u042d\u0442\u043e \u0431\u044b\u043b \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438. \u0410\u043f\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0438 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u043c\u0438, \u0447\u0442\u043e \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0431\u0449\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443, \u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0434\u0435\u0442\u044c\u0441\u044f, \u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0438 \u043a\u043e\u0434, \u043e\u043d\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438. (\u043e\u0442\u0441\u044b\u043b\u0430\u044e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u043a \u0441\u0442\u0430\u0442\u044c\u0435 \u0432 \u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438 (\u043e\u0442\u0441\u044b\u043b\u0430\u044e \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0445 \u043a \u0441\u0442\u0430\u0442\u044c\u0435 \u0432 \u0412\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438:\u00a0<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D0%BE%D0%BF%D1%80%D1%8F%D0%B6%D1%91%D0%BD%D0%BD%D0%BE%D0%B5_%D0%B0%D0%BF%D1%80%D0%B8%D0%BE%D1%80%D0%BD%D0%BE%D0%B5_%D1%80%D0%B0%D1%81%D0%BF%D1%80%D0%B5%D0%B4%D0%B5%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5\" rel=\"noopener noreferrer nofollow\">\u0421\u043e\u043f\u0440\u044f\u0436\u0451\u043d\u043d\u043e\u0435 \u0430\u043f\u0440\u0438\u043e\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/a>). \u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0430\u043f\u0440\u0438\u043e\u0440\u043d\u043e\u0435 \u0438 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043d\u043e \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.  <\/p>\n<p>\u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430 \u2013 \u0437\u0430\u0434\u0430\u0447\u0435 \u043e \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u0438\u0445 \u0431\u0430\u043d\u0434\u0438\u0442\u0430\u0445, \u0438 \u043d\u0430 \u0435\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043d\u044b\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u2013 \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438 (\u0442\u043e \u0435\u0441\u0442\u044c \u043b\u0438\u0431\u043e 1 \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e p, \u043b\u0438\u0431\u043e 0 \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 1-p), \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u043d\u0430\u0433\u0440\u0430\u0434\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u0443 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043d\u043e\u0435 \u0441 \u043d\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u2013 \u0431\u0435\u0442\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435 \u0432 \u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0434\u0430\u043b \u0441\u0441\u044b\u043b\u043a\u0443 \u0432\u044b\u0448\u0435!). \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0435 \u043e \u0431\u0435\u0442\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 (\u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u043c \u2013 \u043a\u043d\u0438\u0433\u0438), \u043d\u043e \u0441\u043a\u0430\u0436\u0443 \u043b\u0438\u0448\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0442 0 \u0434\u043e 1 (\u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c), \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 2 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432: \u0430\u043b\u044c\u0444\u0430 \u0438 \u0431\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0434\u0430\u0447\u043d\u044b\u0445 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0430\u0433\u0440\u0430\u0434\u0443 1) \u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u044b\u0445 (\u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0430\u0433\u0440\u0430\u0434\u0443 0) \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041a\u0430\u0436\u0434\u043e\u043c\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0443 \u0432\u0441\u0435\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b), \u0438\u0437 \u044d\u0442\u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432 1 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u0445 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439. \u0412 \u0438\u0442\u043e\u0433\u0435 &#8212; \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0430 \u043f\u043e\u0442\u043e\u043c, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0430\u0434\u044b, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u041a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">import scipy.stats as stats  class BayesianStrategy_Bin(Strategy):   def __init__(self, n_arms):     self.n_arms = n_arms     self.a = np.ones(n_arms)     self.b = np.ones(n_arms)     self.disr = stats.distributions.beta            def make_action(self):     samples = self.disr.rvs(self.a, self.b)     return np.argmax(samples)        def update(self, action, reward):     if reward:       self.a[action] += 1     else:       self.b[action] += 1            def reset(self):     self.__init__(self.n_arms)<\/code><\/pre>\n<p>\u0410 \u0441\u043c\u044b\u0441\u043b \u0443 \u044d\u0442\u0438\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0442\u0430\u043a\u043e\u0439: \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0443 \u0431\u0435\u0442\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0430\u043b\u044c\u0444\u0430 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439), \u0442\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a 0, \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442 \u2013 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u0435\u0442\u0430 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439), \u0442\u0435\u043c \u0431\u043b\u0438\u0436\u0435 \u043a 1. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0443\u043c\u043c\u0430 \u0430\u043b\u044c\u0444\u0430 \u0438 \u0431\u0435\u0442\u0430, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f. \u042d\u0442\u043e \u0432\u044b\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043b\u0443\u0447\u0448\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0447\u043d\u0435\u0442 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0443\u0442 \u0447\u0430\u0449\u0435!<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e64\/552\/a93\/e64552a93373c752da538d9b7504c3ca.gif\" alt=\"Beta-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\" title=\"Beta-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\" width=\"432\" height=\"288\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e64\/552\/a93\/e64552a93373c752da538d9b7504c3ca.gif\"\/><figcaption>Beta-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/figcaption><\/figure>\n<p>\u041d\u0430 \u0433\u0438\u0444\u043a\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e, \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0444\u0438\u043e\u043b\u0435\u0442\u043e\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0441\u043f\u0440\u0430\u0432\u0430, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0438\u0437 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439.   <\/p>\n<p>\u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u0443: <\/p>\n<pre><code class=\"python\">env = BanditEnv([0.3, 0.2, 0.1, 0.2, 0.9], [1,1,1,1,1])<\/code><\/pre>\n<p>\u0410 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a: <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(150, env, 250, BayesianStrategy_Bin(5)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/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\/4cb\/1b3\/bd0\/4cb1b3bd07051f49482ac01a40f81511.png\" alt=\"Bayesian Strategy (Binary)\" title=\"Bayesian Strategy (Binary)\" width=\"725\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4cb\/1b3\/bd0\/4cb1b3bd07051f49482ac01a40f81511.png\"\/><figcaption>Bayesian Strategy (Binary)<\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u043f\u043e \u043c\u043d\u0435, \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b!<\/p>\n<p>\u0421 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f: \u043c\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u2013 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 (\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0430\u0446\u0438\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0437\u0430\u0448\u043a\u0430\u043b\u0438\u0432\u0430\u0435\u0442). \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u0446\u0435\u043d\u0442\u0440 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u03bc \u2013 \u0441\u0440\u0435\u0434\u043d\u0435\u0435) \u0438 \u0437\u0430 \u0435\u0433\u043e \u0448\u0438\u0440\u0438\u043d\u0443 (\u03c3 \u2013 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435). \u042d\u0442\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/60a\/a9c\/7c0\/60aa9c7c06bbcbb74cecb33174009d20.gif\" alt=\"\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\" title=\"\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\" width=\"432\" height=\"288\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/60a\/a9c\/7c0\/60aa9c7c06bbcbb74cecb33174009d20.gif\"\/><figcaption>\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/figcaption><\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u0442\u043e\u0436\u0435 \u043e\u0442\u0447\u0435\u0442\u043b\u0438\u0432\u043e \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a \u0444\u0438\u043e\u043b\u0435\u0442\u043e\u0432\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u0430\u0432\u0435\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445. \u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e \u043e\u043d\u043e \u0441\u0442\u0430\u043b\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0437\u043a\u0438\u043c \u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u043d\u0435\u0433\u043e \u0431\u044b\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u044d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0438 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0438 \u043d\u0430\u0447\u0430\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041d\u043e \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u044b \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u0438 \u0438 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u0438\u0441\u043a\u0430\u0442\u044c \u0435\u0449\u0435? \u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u0435\u043c \u2013 \u0441\u0442\u0430\u0432\u044f\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0432\u044b\u0448\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0443\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u0430\u0433\u0440\u0430\u0434\u044b \u0438 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u043b\u0435\u0432\u043e, \u0434\u0430\u0432\u0430\u044f \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u0412\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ff7\/ceb\/a08\/ff7ceba08772c19b32af8a6a9dc10c5b.gif\" alt=\"\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c\" title=\"\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c\" width=\"432\" height=\"288\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ff7\/ceb\/a08\/ff7ceba08772c19b32af8a6a9dc10c5b.gif\"\/><figcaption>\u041d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c<\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0443\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435!<\/p>\n<p>\u00a0\u041e \u0442\u043e\u043c \u043a\u0430\u043a \u043e\u043d\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u044b\u0432\u0430\u044e \u0432\u0430\u0441 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0432 \u0432\u0438\u043a\u0438\u043f\u0435\u0434\u0438\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u044b \u0442\u0430\u043c \u0434\u043e\u043b\u044c\u043d\u043e \u043e\u0431\u044a\u0435\u043c\u043d\u044b\u0435. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a: <\/p>\n<pre><code class=\"python\">class BayesianStrategy_Norm(Strategy):   def __init__(self, n_arms, sigma):     self.n_arms = n_arms     self.means = np.ones(n_arms) * 3     self.tay = 1\/(np.ones(n_arms) * sigma)**2     self.tay_likelihood = 1\/(sigma**2)     self.disr = stats.distributions.norm     self.sigma = sigma            def make_action(self):     samples = self.disr.rvs(self.means, np.sqrt(1\/self.tay))     return np.argmax(samples)       def update(self, action, reward):     self.means[action] = (self.tay[action]*self.means[action] + self.tay_likelihood*reward)\/(self.tay[action] + self.tay_likelihood)     self.tay[action] = self.tay[action] + self.tay_likelihood            def reset(self):     self.__init__(self.n_arms, self.sigma)<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0442\u0430\u0443, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u0433\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u044d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0440\u0430\u0441\u0447\u0451\u0442\u044b. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">env = BanditEnv([0.3, 0.2, 0.1, 0.2, 0.9], [1,1,1,1,2]) w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(150, env, 250, BayesianStrategy_Norm(5, 2)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/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\/b6d\/f6b\/cba\/b6df6bcba5b5ec13c2de3cfb02f71e0e.png\" alt=\"Bayesian Strategy (Norm)\" title=\"Bayesian Strategy (Norm)\" width=\"725\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b6d\/f6b\/cba\/b6df6bcba5b5ec13c2de3cfb02f71e0e.png\"\/><figcaption>Bayesian Strategy (Norm)<\/figcaption><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0435 \u0442\u0430\u043a\u0438\u0435 \u0445\u043e\u0440\u043e\u0448\u0438\u0435, \u043a\u0430\u043a \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438, \u043d\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0442\u0435\u043c, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0438 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0430\u044f \u0441\u0440\u0435\u0434\u0430 \u0434\u0440\u0443\u0433\u0430\u044f, \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0442\u044f\u043d\u0443\u0442\u043e \u0437\u0430 \u0443\u0448\u0438 \u0438\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043e\u0431\u0440\u0430\u043d\u044b \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u0440\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full = [],[],[],[] params = [0.5, 1, 2, 5] for param in params:     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(100, env, 250, BayesianStrategy_Norm(5, param))     for f, l in zip([w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full],                   [w_opt_stat, r_avg_stat, r_total_stat, reg_stat]):         f.append(l) plot_stats(w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full, params)<\/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\/79f\/a99\/358\/79fa993588f96b1303a03e0a2ede3514.png\" alt=\"Bayesian Strategy (Norm) parameters\" title=\"Bayesian Strategy (Norm) parameters\" width=\"725\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/79f\/a99\/358\/79fa993588f96b1303a03e0a2ede3514.png\"\/><figcaption>Bayesian Strategy (Norm) parameters<\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043b\u0443\u0447\u0448\u0435! \u041d\u043e \u0432\u0441\u0435 \u043f\u043e\u0437\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435! <\/p>\n<h2>9. \u0412\u0441\u0435 \u043f\u043e\u0437\u043d\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0432\u0441\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u043e\u043c \u0431\u0430\u043d\u0434\u0438\u0442\u0435, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0438\u0445. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u0438 2 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0438\u0445 \u0441\u0440\u0435\u0434\u044b. \u0412 \u043e\u0434\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u043d\u0430\u0433\u0440\u0430\u0434\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043f\u043e \u0437\u0430\u043a\u043e\u043d\u0443 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b\u0438, \u0447\u0442\u043e \u043d\u0430\u0433\u0440\u0430\u0434\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0437\u043d\u0430\u0447\u0438\u0442 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432 2 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442: <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">env = BanditEnv([0.3, 0.2, 0.1, 0.2, 0.9], [1, 1, 1, 1, 2]) w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full = [],[],[],[] params = [Random\u0421hoiceStrategy(5, 20), EpsilonGreedyStrategy(5, 0.2), AnnealingSoftMaxStrategy(5, 0),            UBC1Strategy(5, 1), BayesianStrategy_Norm(5, 0.5)] for param in params:     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(300, env, 250, param)     for f, l in zip([w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full],                   [w_opt_stat, r_avg_stat, r_total_stat, reg_stat]):         f.append(l) plot_stats(w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full, ['random choice','eps greedy','soft max', 'UBC', 'Tompson'])<\/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\/4c2\/cfc\/a79\/4c2cfca79e2d3ecb93312f995f884468.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432\" width=\"724\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4c2\/cfc\/a79\/4c2cfca79e2d3ecb93312f995f884468.png\"\/><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432<\/figcaption><\/figure>\n<p>\u0412\u043f\u043e\u043b\u043d\u0435 \u0447\u0435\u0442\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u0441\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043f\u043e \u0438\u0445 \u0443\u0434\u0430\u0447\u043d\u043e\u0441\u0442\u0438 \u2013 \u043b\u0443\u0447\u0448\u0438\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b <em>softmax<\/em>, <em>UCB<\/em> \u0438 \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0422\u043e\u043c\u043f\u0441\u043e\u043d\u0430, \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u0441\u0435\u0431\u044f \u0447\u0443\u0442\u044c \u0445\u0443\u0436\u0435, \u0430 \u0445\u0443\u0436\u0435 \u0432\u0441\u0435\u0445 \u0441 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u044d\u043f\u0441\u0438\u043b\u043e\u043d-\u0436\u0430\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u043e\u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u0435 \u0441 \u043d\u0430\u0433\u0440\u0430\u0434\u043e\u0439, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u0437\u0430\u043a\u043e\u043d\u0443 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">env = BanditEnv([0.3, 0.2, 0.1, 0.2, 0.9], [1,1,1,1,1]) w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full = [],[],[],[] params = [Random\u0421hoiceStrategy(5, 20), EpsilonGreedyStrategy(5, 0.2), AnnealingSoftMaxStrategy(5, 0),            UBC1Strategy(5, 1), BayesianStrategy_Bin(5)] for param in params:     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(300, env, 250, param)     for f, l in zip([w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full],                   [w_opt_stat, r_avg_stat, r_total_stat, reg_stat]):         f.append(l) plot_stats(w_opt_stat_full, r_avg_stat_full, r_total_stat_full, reg_stat_full, ['random choice','eps greedy', 'soft max', 'UBC', 'Tompson'])<\/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\/2f7\/139\/198\/2f7139198139d2641ff1125f9d9f6072.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432\" width=\"724\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2f7\/139\/198\/2f7139198139d2641ff1125f9d9f6072.png\"\/><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432<\/figcaption><\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0422\u043e\u043c\u043f\u0441\u043e\u043d\u0430 \u043f\u0440\u043e\u044f\u0432\u0438\u043b\u0430 \u0441\u0435\u0431\u044f \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0445! \u0410 \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0440\u0430\u0432\u043d\u0430 \u043b\u0438\u0431\u043e \u043d\u0443\u043b\u044e \u043b\u0438\u0431\u043e \u0435\u0434\u0438\u043d\u0438\u0446\u0435, \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 \u2013 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043e\u0440\u0443\u0436\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 \u043a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u0438\u0445 \u043e\u0440\u0443\u0436\u0438\u0439! \u0410 \u0441 \u0442\u0430\u043a\u0438\u043c \u0430\u0440\u0441\u0435\u043d\u0430\u043b\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c! <\/p>\n<h2>10. \u041f\u0430\u0440\u0430 \u0441\u043b\u043e\u0432 \u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u043d\u0434\u0438\u0442\u0430\u0445<\/h2>\n<p>\u0412 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u0432, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u0442\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u043d\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u0442 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u2013 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u0432. \u041d\u0430\u0433\u0440\u0430\u0434\u0430 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u044b\u043b\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043e, \u043d\u043e \u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043e. \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440: \u0432\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0447\u0435\u043d\u044c \u0430\u0437\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u0433\u0440\u043e\u043a, \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0439 \u0432 \u043a\u0430\u0437\u0438\u043d\u043e, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0440\u0443\u0433, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u0432 \u043a\u0430\u0437\u0438\u043d\u043e, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e \u0441\u0435\u043a\u0440\u0435\u0442\u0443 \u0441\u043a\u0430\u0437\u0430\u043b \u0432\u0430\u043c, \u0447\u0442\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u043d\u044f \u043d\u0435\u0434\u0435\u043b\u0438 \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0438 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u043e\u0432 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f! \u041f\u043e\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u0448\u0430 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f? \u041a\u043e\u043d\u0435\u0447\u043d\u043e! \u042d\u0442\u043e \u0438 \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u043a\u0430\u043a\u043e\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c), \u043d\u043e \u0438 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (\u0432 \u043a\u0430\u043a\u043e\u0439 \u0434\u0435\u043d\u044c \u043d\u0435\u0434\u0435\u043b\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u041c\u043e\u0434\u0435\u043b\u044c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a: <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"formula\" source=\"E\\left[R\\left(a,\\ s\\right)\\right]\\rightarrow\\max_a \\\\ a\\ \\in \\left\\{a_1,a_2,\\ldots,\\ a_n\\right\\},\\ s\\ \\in \\left\\{s_1,s_2,\\ldots,\\ s_n\\right\\}\" alt=\"E\\left[R\\left(a,\\ s\\right)\\right]\\rightarrow\\max_a \\\\ a\\ \\in \\left\\{a_1,a_2,\\ldots,\\ a_n\\right\\},\\ s\\ \\in \\left\\{s_1,s_2,\\ldots,\\ s_n\\right\\}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/02b\/cff\/581\/02bcff581cf5828cb522599aaf15b9bc.svg\" width=\"697\" height=\"59\"\/><\/p>\n<p>\u0418 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0438 \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0438\u0437\u044f\u0449\u043d\u043e\u0435: \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u2013 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u044f \u0441 \u043a\u0430\u0437\u0438\u043d\u043e: \u0432 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0432\u043e \u0432\u0442\u043e\u0440\u043d\u0438\u043a \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u0436\u0435 (\u0430 \u043c\u043e\u0436\u043d\u043e \u0438 \u0434\u0440\u0443\u0433\u043e\u0439) \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u043e \u0437\u0430\u0431\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0432 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a, \u0438 \u0442\u0430\u043a \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0434\u0435\u043b\u0438. \u0410 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a \u043e\u043f\u044f\u0442\u044c \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0432\u0441\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u043f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a\u0430 \u0438 \u0442\u0430\u043a \u043f\u043e \u043d\u043e\u0432\u043e\u0439. <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e \u0432 \u043a\u043e\u0434\u0435. \u0417\u0430\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u0430\u043d\u0434\u0438\u0442, \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u0432. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0431\u0430\u043d\u0434\u0438\u0442\u0430 \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043d\u0430\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u2013 \u043d\u043e\u043c\u0435\u0440 \u0431\u0430\u043d\u0434\u0438\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043e\u043d \u0432\u044b\u0431\u0440\u0430\u043b. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u043d\u0438 \u043d\u0435\u0434\u0435\u043b\u0438 \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 (\u044d\u0442\u043e \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043c\u0435\u043d\u044f\u0435\u0442 \u0441\u0443\u0442\u044c \u0432\u0435\u0449\u0435\u0439).<\/p>\n<pre><code class=\"python\">class ContextualBandit():   def __init__(self, *bandits: BanditEnv, p=None):     self.n_context = len(bandits)     self.bandits = list(bandits)     self.p = p if p else np.ones(shape=(self.n_context,))\/self.n_context            def get_context(self):     self.curr_context = np.random.choice(range(self.n_context),p=self.p)     self.curr_bandit = self.bandits[self.curr_context]     self._optimal_action = self.curr_bandit._optimal_action     self._optimal_reward = self.curr_bandit._optimal_reward     return self.curr_context        def step(self, action):     return self.curr_bandit.reward[action] if np.random.rand(1).item() &lt; self.curr_bandit.probs[action] else 0  contextual_bandit = ContextualBandit(BanditEnv([0.3, 0.2], [1, 1]),                                      BanditEnv([0.1, 0.5], [1, 1]))<\/code><\/pre>\n<p>\u041f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u043c \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u043c\u0435\u0442\u043e\u0434 get_context, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u0432 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u0431\u0430\u043d\u0434\u0438\u0442\u0430. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u043e\u043f\u044f\u0442\u044c 0 \u0438\u043b\u0438 1 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e, \u043d\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u0445 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f. <\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def run_n_episodes(env, strategy, n_episodes):     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = [],[],[],[]     w_opt_times, total_reward, reg = 0, 0, 0     for episode in range(1, n_episodes+1):         curr_context = env.get_context()         action = strategy.make_action()         reward = env.step(action)         strategy.update(action, reward)         w_opt_stat.append(1 if action==env._optimal_action else 0)         total_reward += reward         r_total_stat.append(total_reward)         r_avg_stat.append(total_reward\/episode)         reg += env._optimal_reward - reward         reg_stat.append(reg)     return w_opt_stat, r_avg_stat, r_total_stat, reg_stat<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0436\u0435 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043f\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u044b\u043c \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u043c:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_times(500, contextual_bandit, 250, BayesianStrategy_Bin(2)) plot_stats([w_opt_stat], [r_avg_stat], [r_total_stat], [reg_stat])<\/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\/ad0\/14f\/594\/ad014f594870c4565a925a16c68b8055.png\" alt=\"\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438\" title=\"\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438\" width=\"727\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad0\/14f\/594\/ad014f594870c4565a925a16c68b8055.png\"\/><figcaption>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438<\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u043d\u0438\u0447\u0435\u0433\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0443\u0447\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u0430 50%, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043c\u044b \u0432 50% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u043c, \u0430 \u0432 50% \u043d\u0435\u0442, \u0430 \u043f\u043e\u0442\u0435\u0440\u0438 \u0440\u0430\u0441\u0442\u0443\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0438 \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0442\u044c\u0441\u044f. \u041c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u043d\u0430\u0443\u0433\u0430\u0434, \u0430 \u044d\u0442\u043e \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f. <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u043e\u0436\u0435 \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430: <\/p>\n<pre><code class=\"python\">class ContextualStrategy(Strategy):     def __init__(self, n_context, strategy_base:Strategy, *args):         self.strategy_base = strategy_base         self.n_context = n_context         self.strategys = [strategy_base(*args) for _ in range(n_context)]         self.args = args              def make_action(self, context):         self.curr_strategy = self.strategys[context]         return self.curr_strategy.make_action()          def update(self, action, reward):         self.curr_strategy.update(action, reward)              def reset(self):         self.__init__(self.n_context, self.strategy_base, *self.args)<\/code><\/pre>\n<p>\u0412\u0430\u0436\u043d\u044b\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u043c\u0435\u0442\u043e\u0434 make_action \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u0449\u0435 \u0438 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043d\u0430\u043c \u0441\u043d\u043e\u0432\u0430 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438: <\/p>\n<details class=\"spoiler\">\n<summary>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def run_n_episodes(env, strategy, n_episodes):     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = [],[],[],[]     w_opt_times, total_reward, reg = 0, 0, 0     for episode in range(1, n_episodes+1):         curr_context = env.get_context()         action = strategy.make_action(curr_context)         reward = env.step(action)         strategy.update(action, reward)         w_opt_stat.append(1 if action==env._optimal_action else 0)         total_reward += reward         r_total_stat.append(total_reward)         r_avg_stat.append(total_reward\/episode)         reg += env._optimal_reward - reward         reg_stat.append(reg)     return w_opt_stat, r_avg_stat, r_total_stat, reg_stat<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">w_opt_stat_c, r_avg_stat_c, r_total_stat_c, reg_stat_c = run_n_times(250, contextual_bandit, 250,                                                              ContextualStrategy(2, BayesianStrategy_Bin, 2)) plot_stats([w_opt_stat, w_opt_stat_c], [r_avg_stat, r_avg_stat_c], [r_total_stat, r_total_stat_c], [reg_stat, reg_stat_c], legends=['base', 'contextual'])<\/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\/7bc\/7c3\/775\/7bc7c3775a0cba976d88303ce4971e14.png\" alt=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\" title=\"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\" width=\"721\" height=\"425\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7bc\/7c3\/775\/7bc7c3775a0cba976d88303ce4971e14.png\"\/><figcaption>\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c<\/figcaption><\/figure>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u043d\u0430 \u043b\u0438\u0446\u043e. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0443\u0436\u0435 \u0443\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0438 \u0432 \u0446\u0435\u043b\u043e\u043c \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u043e\u043c \u0431\u0430\u043d\u0434\u0438\u0442\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0443\u0433\u043b\u0443\u0431\u043b\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438! \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0435\u043a\u0442 \u043f\u043e \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u043e\u043c\u0443 \u0431\u0430\u043d\u0434\u0438\u0442\u0443 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e 10 \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0441\u0435 \u0442\u043e, \u0447\u0442\u043e \u043b\u044e\u0431\u044f\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u044b Data Science. <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0437\u0434\u0435\u0441\u044c, \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u0438\u0435 \u0431\u0430\u043d\u0434\u0438\u0442\u044b \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f. \u041c\u044b \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u043e\u0431\u0441\u0443\u0434\u0438\u043b\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0433\u043e\u0440\u0443\u043a\u0438\u0445 \u0431\u0430\u043d\u0434\u0438\u0442\u043e\u0432. \u041d\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443\u043b\u0438 \u0442\u0435\u043c\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <em>Adversarial bandits<\/em> \u0438\u043b\u0438 \u0412\u0440\u0430\u0436\u0434\u0443\u044e\u0449\u0438\u0435 \u0411\u0430\u043d\u0434\u0438\u0442\u044b \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0438 \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u041d\u043e \u043a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f: \u00ab<em>\u0414\u043e\u0440\u043e\u0433\u0443 \u043e\u0441\u0438\u043b\u0438\u0442 \u0438\u0434\u0443\u0449\u0438\u0439!<\/em>\u00bb<\/p>\n<p><em>\u0414\u0430\u043d\u0438\u0438\u043b \u0422\u0440\u0443\u0431\u0438\u043d, \u0413\u043b\u0430\u0432\u043d\u044b\u0439 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u043c\u0430\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u00ab\u0413\u0430\u0437\u043f\u0440\u043e\u043c\u043d\u0435\u0444\u0442\u044c \u2013 \u0420\u0435\u0433\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0434\u0430\u0436\u0438\u00bb<\/em><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/689364\/\"> https:\/\/habr.com\/ru\/post\/689364\/<\/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<h2>1. \u041f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0447\u0442\u043e \u0432\u044b \u043e\u0447\u0435\u043d\u044c \u0430\u0437\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u0433\u0440\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u043b \u0432 \u043a\u0430\u0437\u0438\u043d\u043e \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c, \u0437\u0430 \u043a\u0430\u043a\u043e\u0439 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442 \u0435\u043c\u0443 \u0441\u0435\u0441\u0442\u044c. \u0418\u043b\u0438 \u043e\u0434\u0438\u043d \u043c\u0443\u0440\u0430\u0432\u0435\u0439 \u0438\u0437 \u043a\u043e\u043b\u043e\u043d\u0438\u0438, \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0449\u0438\u0439 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0435\u043c\u0443 \u043f\u043e\u0439\u0442\u0438 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a\u0438 \u043f\u0438\u0449\u0438. \u0418\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432\u044b \u2013 \u044d\u0442\u043e \u0446\u0435\u043b\u044b\u0439 \u043c\u0430\u0440\u043a\u0435\u0442\u043f\u043b\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0443\u043c\u0430\u0435\u0442, \u043a\u0430\u043a\u0443\u044e \u0436\u0435 \u0446\u0435\u043d\u0443, \u0435\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0442\u043e\u0442 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u0442\u043e\u0432\u0430\u0440! <\/p>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b. \u041d\u043e \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434. \u0415\u0441\u043b\u0438 \u043e\u0442\u043a\u0438\u043d\u0443\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0434\u0438\u043b\u0435\u043c\u043c\u0430 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f-\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u043e\u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0430\u043c\u0438: \u043a\u0430\u043a \u0430\u0437\u0430\u0440\u0442\u043d\u044b\u0439 \u0438\u0433\u0440\u043e\u043a, \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442, \u0434\u0430\u044e\u0449\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u043d\u0435\u0433 \u2013 \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u043e \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a\u043e\u0439 \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442 \u0438 \u0438\u0449\u0438\u0442\u0435 \u0435\u0433\u043e, \u0434\u0435\u0440\u0433\u0430\u044f \u0440\u0443\u0447\u043a\u0438 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0432\u044b\u0438\u0433\u0440\u044b\u0448\u0438 \u2013 \u044d\u0442\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435. \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u0438\u0433\u0440\u043e\u0432\u043e\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u0432\u0430\u0448\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u0438\u0431\u044b\u043b\u044c\u043d\u044b\u0439, \u0430 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u0438 \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435? \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043c\u0443\u0440\u0430\u0432\u044c\u044e \u043d\u0443\u0436\u043d\u043e \u0438\u0434\u0442\u0438 \u043f\u043e \u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0433\u0434\u0435 \u0442\u043e\u0432\u0430\u0440\u0438\u0449\u0438-\u043c\u0443\u0440\u0430\u0432\u044c\u0438 \u0443\u0436\u0435 \u043f\u0440\u043e\u0442\u043e\u043f\u0442\u0430\u043b\u0438 \u0442\u0440\u043e\u043f\u0438\u043d\u043a\u0443, \u0430 \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0440\u0438\u0441\u043a\u043d\u0443\u0442\u044c \u0438 \u043f\u043e\u0439\u0442\u0438 \u0441\u0432\u043e\u0435\u0439 \u0434\u043e\u0440\u043e\u0433\u043e\u0439? \u041a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0446\u0435\u043d\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u043f\u0435\u0432\u0430\u0442\u044c \u0437\u0430 \u0438\u043d\u0444\u043b\u044f\u0446\u0438\u0435\u0439 \u0438 \u0441\u043f\u0440\u043e\u0441\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0430 \u0435\u0449\u0435 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0431\u044b\u043b\u044c?<\/p>\n<p>\u041e\u0442\u043a\u0438\u043d\u0435\u043c \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0441\u043b\u043e\u0432\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a\u0438\u043d\u0443\u0442\u044c\u0441\u044f \u0432 \u043c\u043e\u0440\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438 \u0441\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u044d\u0442\u0443 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435: \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 (\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u044b \u0432 \u043a\u0430\u0437\u0438\u043d\u043e, \u043e\u0431\u044a\u0435\u043c\u044b \u043f\u0440\u043e\u0434\u0430\u0436), \u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435. \u042d\u0442\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 <em>a<\/em> \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 <em>{a<sub>1<\/sub>, a<sub>2<\/sub>, \u2026, a<sub>n<\/sub>}<\/em>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0443\u0447\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u043d\u044b\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437 \u0434\u0430\u0432\u0430\u043b\u043e \u0431\u044b \u043d\u0430\u043c \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043b\u044e\u0431\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0431\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u043e \u043c\u043d\u043e\u0433\u043e \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u044b\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0431\u044b \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0436\u0438\u0442\u044c \u0432 \u0442\u043e\u0439, \u0433\u0434\u0435 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0438\u0433\u0440\u0430\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e! \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u0443 \u043d\u0430\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430, \u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0437\u0430 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0439 \u0441\u0440\u043e\u043a. \u0422\u043e \u0435\u0441\u0442\u044c, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u044b \u043f\u043e\u0439\u043c\u0435\u043c \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432\u0435\u0440\u043d\u043e\u0435, \u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0443 \u043d\u0430\u0441 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u00ab\u043d\u0430 \u0440\u0443\u043a\u0430\u0445\u00bb \u0441\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043f\u044b\u0442\u043e\u043a, \u0438\u043b\u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u043b\u0438 \u043d\u0435 \u00ab\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435\u00bb \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043c\u0435\u0442\u0440\u0438\u043a\u0438,<\/em> \u0438 \u043e \u043d\u0438\u0445 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u0438\u0437\u043b\u0438\u0448\u043d\u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0448\u043b\u0438 \u043a \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0439 (\u043e\u0431\u043e\u0431\u0449\u0435\u043d\u043d\u043e\u0439) \u0437\u0430\u0434\u0430\u0447\u0435, \u043c\u043e\u0436\u043d\u043e \u043d\u044b\u0440\u043d\u0443\u0442\u044c \u0432 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438!<\/p>\n<h2>2. \u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043b\u0443\u0447\u0448\u0435?<\/h2>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043d\u0430\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u0411\u043e\u043b\u044c\u0448\u0435 \u0442\u043e\u0433\u043e \u2013 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0435 \u043d\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u044b! <\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f 4 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u044d\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<p>\u041f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u0437\u0433\u043b\u044f\u0434\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u0443\u044e \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0435\u0440\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0438\u043b\u0438 \u043d\u043e\u043b\u0438\u043a \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438. \u041d\u043e \u044d\u0442\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u0441\u0440\u0435\u0434\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b (\u0441\u043f\u043e\u0439\u043b\u0435\u0440: \u0442\u0430\u043a \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c). \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0443\u0447\u043a\u0438, \u00ab\u043e\u0442\u0447\u0438\u0449\u0435\u043d\u043d\u0443\u044e\u00bb \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e! <\/p>\n<p>\u041d\u043e \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u0436\u0438\u0432\u0435\u043c \u0432 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0432\u0441\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043d\u043e\u0433\u043e-\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0441 \u043d\u0443\u043b\u044f (\u0434\u0430 \u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043d\u0430\u0448\u0435 \u0431\u043b\u0430\u0433\u043e\u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u0430\u043a \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043a\u0430\u0437\u0438\u043d\u043e). \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0435\u0449\u0435 \u0442\u0440\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041e\u043d\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0442\u043e\u0436\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0441\u0442\u0438 \u0438, \u0435\u0441\u043b\u0438 \u043c\u044b \u0438\u0445 \u0443\u0441\u0440\u0435\u0434\u043d\u0438\u043c, \u0431\u0443\u0434\u0443\u0442 \u0431\u043e\u043b\u0435\u0435 \u0433\u043b\u0430\u0434\u043a\u0438\u043c\u0438 \u0438 \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u043c\u0438 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u00ab\u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c\u00bb, \u043d\u043e \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u043c \u043e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043c \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0432\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0435\u0441\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u2014 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435 \u0437\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435:<\/p>\n<p>\u0418 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u0435:   <\/p>\n<p>R<em>\u00ad<sub>i<\/sub><\/em> \u2013 \u044d\u0442\u043e \u043d\u0430\u0433\u0440\u0430\u0434\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u0437\u0430 <em>i<\/em>-\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435. <\/p>\n<p>\u0421 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c\u0438 \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430 \u043e\u0434\u043d\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 (\u0438 \u0447\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0441\u0442\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u2013 \u0442\u0435\u043c \u0434\u043b\u044f \u043d\u0430\u0441 \u043b\u0443\u0447\u0448\u0435). \u0410 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043a \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0438 \u0447\u0435\u043c \u043e\u043d \u0431\u043e\u043b\u044c\u0448\u0435 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u2013 \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435). <\/p>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f, \u043d\u043e \u043d\u0435 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u2014 \u044d\u0442\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043f\u043e\u0442\u0435\u0440\u044c (\u0438\u043d\u043e\u0433\u0434\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <em>regret<\/em> \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u0435): <\/p>\n<p>R<sub>opt<\/sub> \u2013 \u044d\u0442\u043e \u0441\u0440\u0435\u0434\u043d\u044f\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438, \u0435\u0441\u043b\u0438 \u0431\u044b \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c. \u0414\u0430\u043d\u043d\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435. \u041f\u043e\u043d\u044f\u0442\u043d\u043e, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043c\u0435\u0442\u0440\u0438\u043a\u0443, \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u0430\u043c\u0438 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u0438 \u0437\u043d\u0430\u0435\u043c \u043a\u0430\u043a\u0430\u044f \u0440\u0443\u0447\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0438 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0430 \u0434\u0430\u0435\u0442 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c. \u041d\u043e \u0447\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u043c? \u041e\u0431\u044b\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435, \u043a\u0430\u043a\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043a\u0430\u043a\u0443\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 \u043c\u044b \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442 \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. \u041e\u0442\u043c\u0435\u0447\u0443 \u0442\u0430\u043a \u0436\u0435, \u0447\u0442\u043e \u044d\u0442\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043d\u0435 \u0442\u0430\u043a \u0436\u0435\u0441\u0442\u043e\u043a\u0430, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u043b\u0438\u0437\u043a\u043e\u0435 \u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u0439\u0434\u0435\u043c\u0441\u044f \u043a \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443, \u043d\u043e \u0431\u043b\u0438\u0437\u043a\u043e\u043c\u0443 \u043a \u043d\u0435\u043c\u0443 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044e, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0435\u0435\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0442\u0435\u0440\u044c, \u0447\u0435\u0433\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f (\u043f\u0435\u0440\u0432\u0430\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430)<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0446\u0435\u043b\u044b\u0445 4 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0438 \u0441\u0430\u043c\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044b!<\/p>\n<h2>3. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/h2>\n<p>\u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0444\u0440\u0430\u0437\u0430: \u00ab\u041f\u043e\u043a\u0430 \u0442\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043a\u043e\u0434\u0435 \u2013 \u0442\u044b \u043d\u0435 \u043f\u043e\u043d\u044f\u043b \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u00bb. \u0422\u0430\u043a \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0438 \u0434\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043a\u0443\u0441\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 Python, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435!<\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0437\u0430\u0434\u0430\u0434\u0438\u043c environment (\u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u0443), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442 \u043d\u0430\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443. \u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0438 \u043f\u043e\u0445\u043e\u0436\u0443\u044e \u043d\u0430 \u043a\u0430\u0437\u0438\u043d\u043e \u043e\u043a\u0440\u0443\u0436\u0430\u044e\u0449\u0443\u044e \u0441\u0440\u0435\u0434\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0432\u044b\u0434\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0438\u0437 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f). \u041d\u043e \u0442\u0430\u043a\u0430\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0438\u0437-\u0437\u0430 \u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0430\u0434\u0430 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. <\/p>\n<pre><code class=\"python\">import numpy as np  class BanditEnv():   def __init__(self, probs, reward):     self.probs = probs     self.reward = reward     self._optimal_action = np.argmax(list(map(lambda x,y: x*y, probs, reward)))     self._optimal_reward = np.max(list(map(lambda x,y: x*y, probs, reward)))    def step(self, action):     return self.reward[action] if np.random.rand(1).item() &lt; self.probs[action] else 0  env = BanditEnv([0.3, 0.2, 0.1, 0.2, 0.9], [1, 1, 1, 1, 2])<\/code><\/pre>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0448\u0430 \u0441\u0440\u0435\u0434\u0430 env \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u0430\u0441\u0441\u0430 BanditEnv \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443 \u043d\u0430\u0441 5 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439: \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 0.3 \u043f\u0435\u0440\u0432\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443 1, \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e 0.2 \u0432\u0442\u043e\u0440\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438\u043d\u0435\u0441\u0435\u0442 \u043d\u0430\u0433\u0440\u0430\u0434\u0443 1 \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u044f\u0442\u043e\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u043d\u0430\u0433\u0440\u0430\u0434\u0443 1.8.   <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 (\u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0435\u043b\u0435\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438). \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <em>\u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441<\/em>. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043e\u0431\u0449\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043c\u0435\u0442\u043e\u0434\u044b (<em>__init__, update, reset<\/em>), \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0440\u0430\u0437 \u0437\u0430 \u0440\u0430\u0437\u043e\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 <em>abstractmethod<\/em> \u043c\u044b \u043e\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u043f\u043e\u0434 \u0442\u0435\u043c \u0436\u0435 \u0438\u043c\u0435\u043d\u0435\u043c. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. <\/p>\n<pre><code class=\"python\">from abc import ABC, abstractmethod  class Strategy(ABC):   def __init__(self, n_arms, epsilon):     self.Q = np.zeros(n_arms)     self.n = [0 for _ in range(n_arms)]     self.epsilon = epsilon     self.n_arms = n_arms        @abstractmethod   def make_action(self):     pass        def update(self, action, reward):     self.n[action] += 1     self.Q[action] = (self.Q[action] * (self.n[action]-1) + reward)\/self.n[action]            def reset(self):     self.__init__(self.n_arms, self.epsilon)<\/code><\/pre>\n<p>\u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0430\u0434\u0443 \u0437\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0435 Q, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u0435\u0434\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0438 \u043a\u0430\u0436\u0434\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 n, \u0430 epsilon \u2013 \u044d\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u044d\u0442\u043e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u0432\u043e\u0439 \u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043c\u044b\u0441\u043b \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435. \u041c\u0435\u0442\u043e\u0434 update \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0430 \u043c\u0435\u0442\u043e\u0434 reset \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0441\u0440\u0435\u0434\u0435, \u0434\u043b\u044f \u0447\u0438\u0441\u0442\u043e\u0442\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0443\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u044e\u0442 \u044d\u043f\u0438\u0437\u043e\u0434\u044b, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439, \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0438 \u0440\u0438\u0441\u0443\u044e\u0442 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043b\u0435\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">from tqdm import tqdm import matplotlib.pyplot as plt  def run_n_episodes(env, strategy, n_episodes):   w_opt_stat, r_avg_stat, r_total_stat, reg_stat = [],[],[],[]   w_opt_times, total_reward, reg = 0, 0, 0   for episode in range(1, n_episodes+1):     action = strategy.make_action()     reward = env.step(action)     strategy.update(action, reward)     w_opt_stat.append(1 if action==env._optimal_action else 0)     total_reward += reward     r_total_stat.append(total_reward)     r_avg_stat.append(total_reward\/episode)     reg += env._optimal_reward - reward     reg_stat.append(reg)   return w_opt_stat, r_avg_stat, r_total_stat, reg_stat  def run_n_times(n_repeat, env, n_episodes, strategy):   w_opt_stat_full, r_avg_stat_full = [],[]   r_total_stat_full, reg_stat_full = [],[]   for _ in tqdm(range(n_repeat)):     strategy.reset()     w_opt_stat, r_avg_stat, r_total_stat, reg_stat = run_n_episodes(env,                                                                      strategy,                                                                     n_episodes)     w_opt_stat_full.append(w_opt_stat)     r_avg_stat_full.append(r_avg_stat)     r_total_stat_full.append(r_total_stat)     reg_stat_full.append(reg_stat)   return<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-338560","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338560","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=338560"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338560\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}