{"id":457301,"date":"2025-04-25T03:00:09","date_gmt":"2025-04-25T03:00:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=457301"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=457301","title":{"rendered":"<span>\u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0435 \u0410\/\u0411-\u0442\u0435\u0441\u0442\u044b: \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u043a \u0410\/\u0411-\u0442\u0435\u0441\u0442\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 \u0441 3 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438. \u041b\u0443\u0447\u0448\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439. \u0421\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/em><\/p>\n<p>\u0411\u043b\u043e\u043a\u043d\u043e\u0442: <a href=\"https:\/\/github.com\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/appendices\/%D0%9C%D0%BD%D0%BE%D0%B6%D0%B5%D1%81%D1%82%D0%B2%D0%B5%D0%BD%D0%BD%D1%8B%D0%B5_%D1%81%D1%80%D0%B0%D0%B2%D0%BD%D0%B5%D0%BD%D0%B8%D1%8F.ipynb\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/appendices\/\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435_\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.ipynb<\/a> . <\/p>\n<details class=\"spoiler\">\n<summary>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import scipy.stats as stats import plotly.graph_objects as go  np.random.seed(7)<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0412 \u0410\/\u0411-\u0442\u0435\u0441\u0442\u0430\u0445 \u0431\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. &#171;\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0433\u0438\u043f\u043e\u0442\u0435\u0437&#187; \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043f\u0440\u0430\u0432\u043e\u043a \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f [<a href=\"https:\/\/en.wikipedia.org\/wiki\/Multiple_comparisons_problem\" rel=\"noopener noreferrer nofollow\">MultipleComp<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Family-wise_error_rate\" rel=\"noopener noreferrer nofollow\">FWER<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bonferroni_correction\" rel=\"noopener noreferrer nofollow\">Bonf<\/a>]. \u0412 \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043b\u0443\u0447\u0448\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>\u041d\u0430 \u0442\u0440\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b A, B \u0438 \u0421 \u0437\u0430\u0448\u043b\u043e \u043f\u043e <img decoding=\"async\" class=\"formula inline\" source=\"N=1000\" alt=\"N=1000\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bf0\/bf03db6e35003ccc3459dc56be75bf2a.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bf0\/bf03db6e35003ccc3459dc56be75bf2a.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bf0\/bf03db6e35003ccc3459dc56be75bf2a.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041a\u043d\u043e\u043f\u043a\u0443 &#171;\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c&#187; \u043d\u0430\u0436\u0430\u043b\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"n_{s_A}=100\" alt=\"n_{s_A}=100\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/fe\/fe7\/fe73ce51b109fb54f7afeadd9a615ee5.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/fe\/fe7\/fe73ce51b109fb54f7afeadd9a615ee5.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f\/fe\/fe7\/fe73ce51b109fb54f7afeadd9a615ee5.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, <img decoding=\"async\" class=\"formula inline\" source=\"n_{s_B}=105\" alt=\"n_{s_B}=105\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46c\/d33\/b84\/46cd33b84ecf580f20c9308c2a00704b.svg\" width=\"85\" height=\"22\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46c\/d33\/b84\/46cd33b84ecf580f20c9308c2a00704b.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46c\/d33\/b84\/46cd33b84ecf580f20c9308c2a00704b.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, <img decoding=\"async\" class=\"formula inline\" source=\"n_{s_C}=110\" alt=\"n_{s_C}=110\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a7\/a74\/a74f9659db3a8a9753016fe1d78fc270.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a7\/a74\/a74f9659db3a8a9753016fe1d78fc270.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a7\/a74\/a74f9659db3a8a9753016fe1d78fc270.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0421 \u043a\u0430\u043a\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043b\u0443\u0447\u0448\u0430\u044f?<\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0433\u0440\u0443\u043f\u043f: <img decoding=\"async\" class=\"formula inline\" source=\"P(\\text{Best } A) \\equiv P(p_A &gt; p_B \\cap p_A &gt; p_C)\" alt=\"P(\\text{Best } A) \\equiv P(p_A &gt; p_B \\cap p_A &gt; p_C)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bfb\/bfb223b1d560eb988841b6c71582ea8d.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bfb\/bfb223b1d560eb988841b6c71582ea8d.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bf\/bfb\/bfb223b1d560eb988841b6c71582ea8d.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0434\u043b\u044f \u0410, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f B \u0438 C. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"P(\\mathcal{D} | \\mathcal{H})\" alt=\"P(\\mathcal{D} | \\mathcal{H})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/26\/269\/269b7b8e9f3c6d68d6eb468e58b133d5.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/26\/269\/269b7b8e9f3c6d68d6eb468e58b133d5.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/26\/269\/269b7b8e9f3c6d68d6eb468e58b133d5.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c, \u0430\u043f\u0440\u0438\u043e\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"P(\\mathcal{H})\" alt=\"P(\\mathcal{H})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a9\/a91\/a91aa2752367a283ab5e0b3d072e60c9.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a9\/a91\/a91aa2752367a283ab5e0b3d072e60c9.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/a\/a9\/a91\/a91aa2752367a283ab5e0b3d072e60c9.svg 781w\" loading=\"lazy\" decode=\"async\"\/> &#8212; \u0431\u0435\u0442\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <img decoding=\"async\" class=\"formula inline\" source=\"P(\\mathcal{H} | \\mathcal{D})\" alt=\"P(\\mathcal{H} | \\mathcal{D})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/0e\/0ed\/0edd877577ef296a45791d0c41b99826.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/0e\/0ed\/0edd877577ef296a45791d0c41b99826.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0\/0e\/0ed\/0edd877577ef296a45791d0c41b99826.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0431\u0435\u0442\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c\u0438 [<a href=\"https:\/\/nbviewer.org\/github\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/%D0%91%D0%B0%D0%B9%D0%B5%D1%81%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F_%D0%BE%D1%86%D0%B5%D0%BD%D0%BA%D0%B0_%D0%90%D0%91-%D1%82%D0%B5%D1%81%D1%82%D0%BE%D0%B2.ipynb#%D0%9A%D0%BE%D0%BD%D0%B2%D0%B5%D1%80%D1%81%D0%B8%D0%B8\" rel=\"noopener noreferrer nofollow\">BayesABConv<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Beta_distribution\" rel=\"noopener noreferrer nofollow\">BetaDist<\/a>, <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.stats.beta.html\" rel=\"noopener noreferrer nofollow\">SciPyBeta<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conjugate_prior\" rel=\"noopener noreferrer nofollow\">ConjPrior<\/a>].<\/p>\n<p><img decoding=\"async\" class=\"formula\" source=\"P(\\mathcal{H} | \\mathcal{D}) \\propto P(\\mathcal{D} | \\mathcal{H}) P(\\mathcal{H})\" alt=\"P(\\mathcal{H} | \\mathcal{D}) \\propto P(\\mathcal{D} | \\mathcal{H}) P(\\mathcal{H})\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c39\/301\/469\/c393014691e883a485627b0ed9bd5c43.svg\" width=\"207\" height=\"22\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c39\/301\/469\/c393014691e883a485627b0ed9bd5c43.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c39\/301\/469\/c393014691e883a485627b0ed9bd5c43.svg 781w\" loading=\"lazy\" decode=\"async\"\/><img decoding=\"async\" class=\"formula\" source=\"P(\\mathcal{D} | \\mathcal{H}) = P(n_s, N | p) = \\mbox{Binom}(n_s, N | p) = C_{N}^{n_s} p^{n_s} (1-p)^{N-n_s}\" alt=\"P(\\mathcal{D} | \\mathcal{H}) = P(n_s, N | p) = \\mbox{Binom}(n_s, N | p) = C_{N}^{n_s} p^{n_s} (1-p)^{N-n_s}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/687\/d50\/b0c\/687d50b0cf9957a4d53d49d1ecf31061.svg\" width=\"527\" height=\"27\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/687\/d50\/b0c\/687d50b0cf9957a4d53d49d1ecf31061.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/687\/d50\/b0c\/687d50b0cf9957a4d53d49d1ecf31061.svg 781w\" loading=\"lazy\" decode=\"async\"\/><img decoding=\"async\" class=\"formula\" source=\"P(\\mathcal{H}) = P(p) = \\mbox{Beta}(p; \\alpha, \\beta) = \\frac{\\Gamma(\\alpha + \\beta)}{\\Gamma(\\alpha) \\Gamma(\\beta)} p^{\\alpha-1}(1-p)^{\\beta-1}\" alt=\"P(\\mathcal{H}) = P(p) = \\mbox{Beta}(p; \\alpha, \\beta) = \\frac{\\Gamma(\\alpha + \\beta)}{\\Gamma(\\alpha) \\Gamma(\\beta)} p^{\\alpha-1}(1-p)^{\\beta-1}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/36\/36e\/36eafca74d4f46eff86c3d93414d55ea.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/36\/36e\/36eafca74d4f46eff86c3d93414d55ea.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3\/36\/36e\/36eafca74d4f46eff86c3d93414d55ea.svg 781w\" loading=\"lazy\" decode=\"async\"\/><img decoding=\"async\" class=\"formula\" source=\"\\begin{split}P(\\mathcal{H} | \\mathcal{D}) &amp; = P(p | n_s, N) = \\mbox{Beta}(p; \\alpha + n_s, \\beta + N - n_s)\\end{split}\" alt=\"\\begin{split}P(\\mathcal{H} | \\mathcal{D}) &amp; = P(p | n_s, N) = \\mbox{Beta}(p; \\alpha + n_s, \\beta + N - n_s)\\end{split}\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/495\/2f5\/3ba\/4952f53ba99fc19044139cef06f47d67.svg\" width=\"454\" height=\"24\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/495\/2f5\/3ba\/4952f53ba99fc19044139cef06f47d67.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/495\/2f5\/3ba\/4952f53ba99fc19044139cef06f47d67.svg 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p>\u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b. \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 <img decoding=\"async\" class=\"formula inline\" source=\"P(\\text{Best } A) = 15\\%\" alt=\"P(\\text{Best } A) = 15\\%\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee2\/ee2bd0dab3737e8c5afed47a72dccd2b.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee2\/ee2bd0dab3737e8c5afed47a72dccd2b.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ee\/ee2\/ee2bd0dab3737e8c5afed47a72dccd2b.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, <img decoding=\"async\" class=\"formula inline\" source=\"P(\\text{Best } B) = 30\\%\" alt=\"P(\\text{Best } B) = 30\\%\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/2c\/2c5\/2c5ee4d81c6cd7182d80643d087072e9.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/2c\/2c5\/2c5ee4d81c6cd7182d80643d087072e9.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/2\/2c\/2c5\/2c5ee4d81c6cd7182d80643d087072e9.svg 781w\" loading=\"lazy\" decode=\"async\"\/>, <img decoding=\"async\" class=\"formula inline\" source=\"P(\\text{Best } C) = 55\\%\" alt=\"P(\\text{Best } C) = 55\\%\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ed\/edc\/edc4dc6b2bc70ab104d51acf1bd58d1d.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ed\/edc\/edc4dc6b2bc70ab104d51acf1bd58d1d.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/e\/ed\/edc\/edc4dc6b2bc70ab104d51acf1bd58d1d.svg 781w\" loading=\"lazy\" decode=\"async\"\/>.<\/p>\n<details class=\"spoiler\">\n<summary>\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def posterior_dist_binom(ns, ntotal, a_prior=1, b_prior=1):     a = a_prior + ns     b = b_prior + ntotal - ns      return stats.beta(a=a, b=b)  N = 1000 sa = 100 sb = 105 sc = 110  p_dist_a = posterior_dist_binom(ns=sa, ntotal=N) p_dist_b = posterior_dist_binom(ns=sb, ntotal=N) p_dist_c = posterior_dist_binom(ns=sc, ntotal=N)  npost = 50000 samp_a = p_dist_a.rvs(size=npost) samp_b = p_dist_b.rvs(size=npost) samp_c = p_dist_c.rvs(size=npost)  p_a_best = np.sum((samp_a &gt; samp_b) &amp; (samp_a &gt; samp_c)) \/ npost p_b_best = np.sum((samp_b &gt; samp_a) &amp; (samp_b &gt; samp_c)) \/ npost p_c_best = np.sum((samp_c &gt; samp_a) &amp; (samp_c &gt; samp_b)) \/ npost  xaxis_max = 0.2 x = np.linspace(0, xaxis_max, 1000) fig = go.Figure() fig.add_trace(go.Scatter(x=x, y=p_dist_a.pdf(x), line_color='black', name='A')) fig.add_trace(go.Scatter(x=x, y=p_dist_b.pdf(x), line_color='black', line_dash='longdash', name='B')) fig.add_trace(go.Scatter(x=x, y=p_dist_c.pdf(x), line_color='black', line_dash='dot', name='C')) fig.update_layout(title='\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f',                   xaxis_title='$p$',                   yaxis_title='\u041f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438',                   xaxis_range=[0, xaxis_max],                   hovermode=\"x\",                   height=500) fig.show()  print(f\"P Best:\") print(f\"P(Best A) = P(A&gt;B &amp; A&gt;C) = {p_a_best}\") print(f\"P(Best B) = P(B&gt;A &amp; B&gt;C) = {p_b_best}\") print(f\"P(Best C) = P(C&gt;A &amp; C&gt;B) = {p_c_best}\")<\/code><\/pre>\n<pre><code>P Best: P(Best A) = P(A&gt;B &amp; A&gt;C) = 0.14664 P(Best B) = P(B&gt;A &amp; B&gt;C) = 0.30228 P(Best C) = P(C&gt;A &amp; C&gt;B) = 0.55108<\/code><\/pre>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/892\/593\/d77\/892593d778631d67431881fae8c7ecd9.png\" alt=\"\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 3 \u0433\u0440\u0443\u043f\u043f. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 P(Best A) = 15%, P(Best B) = 30%, P(Best C) = 55%.\" title=\"\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 3 \u0433\u0440\u0443\u043f\u043f. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 P(Best A) = 15%, P(Best B) = 30%, P(Best C) = 55%.\" width=\"1400\" height=\"1000\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/892\/593\/d77\/892593d778631d67431881fae8c7ecd9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/892\/593\/d77\/892593d778631d67431881fae8c7ecd9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 3 \u0433\u0440\u0443\u043f\u043f. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 P(Best A) = 15%, P(Best B) = 30%, P(Best C) = 55%.<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0432 \u0441\u0435\u0440\u0438\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u0412 \u0433\u0440\u0443\u043f\u043f\u0435 A \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f <code>p = 0.1<\/code>, \u0432 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 B \u0438 C \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 <img decoding=\"async\" class=\"formula inline\" source=\"\\pm 5\\%\" alt=\"\\pm 5\\%\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d4\/d4b\/d4b6e0e61c17556d8e57b4cea1c587b7.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d4\/d4b\/d4b6e0e61c17556d8e57b4cea1c587b7.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d\/d4\/d4b\/d4b6e0e61c17556d8e57b4cea1c587b7.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u043e\u0442 <code>p<\/code>. \u0412 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0448\u0430\u0433\u043e\u043c <code>n_samp_step<\/code>. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0433\u0440\u0443\u043f\u043f <img decoding=\"async\" class=\"formula inline\" source=\"P(\\text{Best } A)\" alt=\"P(\\text{Best } A)\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bd\/bde\/bde923442fb8e9a3619669ebf893557f.svg\" width=\"auto\" height=\"auto\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bd\/bde\/bde923442fb8e9a3619669ebf893557f.svg 780w,&#10;       https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b\/bd\/bde\/bde923442fb8e9a3619669ebf893557f.svg 781w\" loading=\"lazy\" decode=\"async\"\/> \u0438 \u0434\u0440. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 <code>prob_stop=0.95<\/code> \u0438\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a <code>n_samp_max<\/code>. \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f <code>nexps<\/code> \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 <code>nexps = 1000<\/code> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043e 951. \u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c 0.951 \u0431\u043b\u0438\u0437\u043a\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439 <code>prob_stop = 0.95<\/code>.<\/p>\n<p><code>Nexp: 1000, Correct Guesses: 951, Accuracy: 0.951<\/code><\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432 \u0441\u0435\u0440\u0438\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def p_best(*args, n_post_samp=50_000):     samp = [d.rvs(size=n_post_samp) for d in args]     best_group = np.argmax(np.vstack(samp), axis=0)     u = np.unique(best_group, return_counts=True)     p_best = np.zeros(len(args))     for i, c in zip(u[0], u[1]):         p_best[i] = c     p_best = p_best \/ n_post_samp     return p_best  cmp = pd.DataFrame(columns=['A', 'B', 'C', 'best_exact',                              'exp_samp_size', 'A_exp', 'B_exp', 'C_exp',                              'best_exp', 'p_best'])  p = 0.1 nexps = 1000 cmp['A'] = [p] * nexps cmp['B'] = p * (1 + stats.uniform.rvs(loc=-0.05, scale=0.1, size=nexps)) cmp['C'] = p * (1 + stats.uniform.rvs(loc=-0.05, scale=0.1, size=nexps)) cmp['best_exact'] = cmp.apply(lambda r: 'A' if r['A'] &gt; r['B'] and r['A'] &gt; r['C'] else 'B' if r['B'] &gt; r['A'] and r['B'] &gt; r['C'] else 'C', axis=1)  n_samp_max = 30_000_000 n_samp_step = 10_000 prob_stop = 0.95  for i in range(nexps):     pA = cmp.at[i, 'A']     pB = cmp.at[i, 'B']     pC = cmp.at[i, 'C']     exact_dist_A = stats.bernoulli(p=pA)     exact_dist_B = stats.bernoulli(p=pB)     exact_dist_C = stats.bernoulli(p=pC)     n_samp_total = 0     ns_A = 0     ns_B = 0     ns_C = 0     while n_samp_total &lt; n_samp_max:         dA = exact_dist_A.rvs(n_samp_step)         dB = exact_dist_B.rvs(n_samp_step)         dC = exact_dist_C.rvs(n_samp_step)         n_samp_total += n_samp_step         ns_A = ns_A + np.sum(dA)         ns_B = ns_B + np.sum(dB)         ns_C = ns_C + np.sum(dC)         post_dist_A = posterior_dist_binom(ns=ns_A, ntotal=n_samp_total)         post_dist_B = posterior_dist_binom(ns=ns_B, ntotal=n_samp_total)         post_dist_C = posterior_dist_binom(ns=ns_C, ntotal=n_samp_total)         p_best_A, p_best_B, p_best_C = p_best(post_dist_A, post_dist_B, post_dist_C)         best_gr = 'A' if p_best_A &gt;= prob_stop else 'B' if  p_best_B &gt;= prob_stop else 'C' if p_best_C &gt;= prob_stop else None         if best_gr:             cmp.at[i, 'A_exp'] = post_dist_A.mean()             cmp.at[i, 'B_exp'] = post_dist_B.mean()             cmp.at[i, 'C_exp'] = post_dist_C.mean()             cmp.at[i, 'exp_samp_size'] = n_samp_total             cmp.at[i, 'best_exp'] = best_gr             cmp.at[i, 'p_best'] = max(p_best_A, p_best_B, p_best_C)             break     print(f'done {i}: nsamp {n_samp_total}, best_gr {best_gr}, P_best {max(p_best_A, p_best_B, p_best_C)}')  cmp['correct'] = cmp['best_exact'] == cmp['best_exp'] display(cmp.head(20)) cor_guess = np.sum(cmp['correct']) print(f\"Nexp: {nexps}, Correct Guesses: {cor_guess}, Accuracy: {cor_guess \/ nexps}\")<\/code><\/pre>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1db\/839\/ddd\/1db839ddd964cc169eb55b69aefc7c84.png\" width=\"1218\" height=\"742\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/1db\/839\/ddd\/1db839ddd964cc169eb55b69aefc7c84.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1db\/839\/ddd\/1db839ddd964cc169eb55b69aefc7c84.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<\/div>\n<\/details>\n<p>\u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u043a \u0410\/\u0411-\u0442\u0435\u0441\u0442\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 \u0441 3 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438. \u041b\u0443\u0447\u0448\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439. \u0421\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438<\/strong>:<\/p>\n<p>[BayesABConv] &#8212; <a href=\"https:\/\/nbviewer.org\/github\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/%D0%91%D0%B0%D0%B9%D0%B5%D1%81%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F_%D0%BE%D1%86%D0%B5%D0%BD%D0%BA%D0%B0_%D0%90%D0%91-%D1%82%D0%B5%D1%81%D1%82%D0%BE%D0%B2.ipynb#%D0%9A%D0%BE%D0%BD%D0%B2%D0%B5%D1%80%D1%81%D0%B8%D0%B8\" rel=\"noopener noreferrer nofollow\">Bayesian A\/B-Testing<\/a>, <em>GitHub.<\/em><br \/>[BetaDist] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Beta_distribution\" rel=\"noopener noreferrer nofollow\">Beta Distribution<\/a>, <em>Wikipedia.<\/em><br \/>[Bonf] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bonferroni_correction\" rel=\"noopener noreferrer nofollow\">Bonferroni Correction<\/a>, <em>Wikipedia.<\/em><br \/>[ConjPrior] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conjugate_prior\" rel=\"noopener noreferrer nofollow\">Conjugate Prior<\/a>, <em>Wikipedia.<\/em><br \/>[FWER] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Family-wise_error_rate\" rel=\"noopener noreferrer nofollow\">Family-wise Error Rate<\/a>, <em>Wikipedia.<\/em><br \/>[MultipleComp] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Multiple_comparisons_problem\" rel=\"noopener noreferrer nofollow\">Multiple Comparisons Problem<\/a>, <em>Wikipedia.<\/em><br \/>[SciPyBeta] &#8212; <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.stats.beta.html\" rel=\"noopener noreferrer nofollow\">scipy.stats.beta<\/a>, <em>SciPy Reference.<\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/903820\/\"> https:\/\/habr.com\/ru\/articles\/903820\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u043a \u0410\/\u0411-\u0442\u0435\u0441\u0442\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 \u0441 3 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438. \u041b\u0443\u0447\u0448\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439. \u0421\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/em><\/p>\n<p>\u0411\u043b\u043e\u043a\u043d\u043e\u0442: <a href=\"https:\/\/github.com\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/appendices\/%D0%9C%D0%BD%D0%BE%D0%B6%D0%B5%D1%81%D1%82%D0%B2%D0%B5%D0%BD%D0%BD%D1%8B%D0%B5_%D1%81%D1%80%D0%B0%D0%B2%D0%BD%D0%B5%D0%BD%D0%B8%D1%8F.ipynb\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/appendices\/\u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435_\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f.ipynb<\/a> . <\/p>\n<details class=\"spoiler\">\n<summary>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import numpy as np import pandas as pd import scipy.stats as stats import plotly.graph_objects as go  np.random.seed(7)<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0412 \u0410\/\u0411-\u0442\u0435\u0441\u0442\u0430\u0445 \u0431\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. &#171;\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0433\u0438\u043f\u043e\u0442\u0435\u0437&#187; \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043f\u0440\u0430\u0432\u043e\u043a \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f [<a href=\"https:\/\/en.wikipedia.org\/wiki\/Multiple_comparisons_problem\" rel=\"noopener noreferrer nofollow\">MultipleComp<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Family-wise_error_rate\" rel=\"noopener noreferrer nofollow\">FWER<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bonferroni_correction\" rel=\"noopener noreferrer nofollow\">Bonf<\/a>]. \u0412 \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043b\u0443\u0447\u0448\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u043f\u0440\u0430\u0432\u043a\u0438 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>\u041d\u0430 \u0442\u0440\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b A, B \u0438 \u0421 \u0437\u0430\u0448\u043b\u043e \u043f\u043e  \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u041a\u043d\u043e\u043f\u043a\u0443 &#171;\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c&#187; \u043d\u0430\u0436\u0430\u043b\u0438 , ,  \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0421 \u043a\u0430\u043a\u043e\u0439 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043b\u0443\u0447\u0448\u0430\u044f?<\/p>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0433\u0440\u0443\u043f\u043f:  \u0434\u043b\u044f \u0410, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043b\u044f B \u0438 C. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043e\u043a \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439. \u0414\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u0435  \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c, \u0430\u043f\u0440\u0438\u043e\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435  &#8212; \u0431\u0435\u0442\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f  \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0443\u0442 \u0431\u0435\u0442\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f\u043c\u0438 [<a href=\"https:\/\/nbviewer.org\/github\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/%D0%91%D0%B0%D0%B9%D0%B5%D1%81%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F_%D0%BE%D1%86%D0%B5%D0%BD%D0%BA%D0%B0_%D0%90%D0%91-%D1%82%D0%B5%D1%81%D1%82%D0%BE%D0%B2.ipynb#%D0%9A%D0%BE%D0%BD%D0%B2%D0%B5%D1%80%D1%81%D0%B8%D0%B8\" rel=\"noopener noreferrer nofollow\">BayesABConv<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Beta_distribution\" rel=\"noopener noreferrer nofollow\">BetaDist<\/a>, <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.stats.beta.html\" rel=\"noopener noreferrer nofollow\">SciPyBeta<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conjugate_prior\" rel=\"noopener noreferrer nofollow\">ConjPrior<\/a>].<\/p>\n<p>\u041d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0433\u0440\u0443\u043f\u043f\u044b. \u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 , , .<\/p>\n<details class=\"spoiler\">\n<summary>\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def posterior_dist_binom(ns, ntotal, a_prior=1, b_prior=1):     a = a_prior + ns     b = b_prior + ntotal - ns      return stats.beta(a=a, b=b)  N = 1000 sa = 100 sb = 105 sc = 110  p_dist_a = posterior_dist_binom(ns=sa, ntotal=N) p_dist_b = posterior_dist_binom(ns=sb, ntotal=N) p_dist_c = posterior_dist_binom(ns=sc, ntotal=N)  npost = 50000 samp_a = p_dist_a.rvs(size=npost) samp_b = p_dist_b.rvs(size=npost) samp_c = p_dist_c.rvs(size=npost)  p_a_best = np.sum((samp_a &gt; samp_b) &amp; (samp_a &gt; samp_c)) \/ npost p_b_best = np.sum((samp_b &gt; samp_a) &amp; (samp_b &gt; samp_c)) \/ npost p_c_best = np.sum((samp_c &gt; samp_a) &amp; (samp_c &gt; samp_b)) \/ npost  xaxis_max = 0.2 x = np.linspace(0, xaxis_max, 1000) fig = go.Figure() fig.add_trace(go.Scatter(x=x, y=p_dist_a.pdf(x), line_color='black', name='A')) fig.add_trace(go.Scatter(x=x, y=p_dist_b.pdf(x), line_color='black', line_dash='longdash', name='B')) fig.add_trace(go.Scatter(x=x, y=p_dist_c.pdf(x), line_color='black', line_dash='dot', name='C')) fig.update_layout(title='\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f',                   xaxis_title='$p$',                   yaxis_title='\u041f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438',                   xaxis_range=[0, xaxis_max],                   hovermode=\"x\",                   height=500) fig.show()  print(f\"P Best:\") print(f\"P(Best A) = P(A&gt;B &amp; A&gt;C) = {p_a_best}\") print(f\"P(Best B) = P(B&gt;A &amp; B&gt;C) = {p_b_best}\") print(f\"P(Best C) = P(C&gt;A &amp; C&gt;B) = {p_c_best}\")<\/code><\/pre>\n<pre><code>P Best: P(Best A) = P(A&gt;B &amp; A&gt;C) = 0.14664 P(Best B) = P(B&gt;A &amp; B&gt;C) = 0.30228 P(Best C) = P(C&gt;A &amp; C&gt;B) = 0.55108<\/code><\/pre>\n<\/div>\n<\/details>\n<figure class=\"full-width\">\n<div><figcaption>\u0410\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 3 \u0433\u0440\u0443\u043f\u043f. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 P(Best A) = 15%, P(Best B) = 30%, P(Best C) = 55%.<\/figcaption><\/div>\n<\/figure>\n<p>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0432 \u0441\u0435\u0440\u0438\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u0412 \u0433\u0440\u0443\u043f\u043f\u0435 A \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f <code>p = 0.1<\/code>, \u0432 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 B \u0438 C \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435  \u043e\u0442 <code>p<\/code>. \u0412 \u0433\u0440\u0443\u043f\u043f\u0430\u0445 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0448\u0430\u0433\u043e\u043c <code>n_samp_step<\/code>. \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0448\u0430\u0433\u0435 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043b\u0443\u0447\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0433\u0440\u0443\u043f\u043f  \u0438 \u0434\u0440. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0433\u0440\u0443\u043f\u043f \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 <code>prob_stop=0.95<\/code> \u0438\u043b\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a <code>n_samp_max<\/code>. \u041f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u0441\u044f <code>nexps<\/code> \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432, \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 <code>nexps = 1000<\/code> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043e 951. \u0422\u043e\u0447\u043d\u043e\u0441\u0442\u044c 0.951 \u0431\u043b\u0438\u0437\u043a\u0430 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439 <code>prob_stop = 0.95<\/code>.<\/p>\n<p><code>Nexp: 1000, Correct Guesses: 951, Accuracy: 0.951<\/code><\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u0433\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432 \u0441\u0435\u0440\u0438\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">def p_best(*args, n_post_samp=50_000):     samp = [d.rvs(size=n_post_samp) for d in args]     best_group = np.argmax(np.vstack(samp), axis=0)     u = np.unique(best_group, return_counts=True)     p_best = np.zeros(len(args))     for i, c in zip(u[0], u[1]):         p_best[i] = c     p_best = p_best \/ n_post_samp     return p_best  cmp = pd.DataFrame(columns=['A', 'B', 'C', 'best_exact',                              'exp_samp_size', 'A_exp', 'B_exp', 'C_exp',                              'best_exp', 'p_best'])  p = 0.1 nexps = 1000 cmp['A'] = [p] * nexps cmp['B'] = p * (1 + stats.uniform.rvs(loc=-0.05, scale=0.1, size=nexps)) cmp['C'] = p * (1 + stats.uniform.rvs(loc=-0.05, scale=0.1, size=nexps)) cmp['best_exact'] = cmp.apply(lambda r: 'A' if r['A'] &gt; r['B'] and r['A'] &gt; r['C'] else 'B' if r['B'] &gt; r['A'] and r['B'] &gt; r['C'] else 'C', axis=1)  n_samp_max = 30_000_000 n_samp_step = 10_000 prob_stop = 0.95  for i in range(nexps):     pA = cmp.at[i, 'A']     pB = cmp.at[i, 'B']     pC = cmp.at[i, 'C']     exact_dist_A = stats.bernoulli(p=pA)     exact_dist_B = stats.bernoulli(p=pB)     exact_dist_C = stats.bernoulli(p=pC)     n_samp_total = 0     ns_A = 0     ns_B = 0     ns_C = 0     while n_samp_total &lt; n_samp_max:         dA = exact_dist_A.rvs(n_samp_step)         dB = exact_dist_B.rvs(n_samp_step)         dC = exact_dist_C.rvs(n_samp_step)         n_samp_total += n_samp_step         ns_A = ns_A + np.sum(dA)         ns_B = ns_B + np.sum(dB)         ns_C = ns_C + np.sum(dC)         post_dist_A = posterior_dist_binom(ns=ns_A, ntotal=n_samp_total)         post_dist_B = posterior_dist_binom(ns=ns_B, ntotal=n_samp_total)         post_dist_C = posterior_dist_binom(ns=ns_C, ntotal=n_samp_total)         p_best_A, p_best_B, p_best_C = p_best(post_dist_A, post_dist_B, post_dist_C)         best_gr = 'A' if p_best_A &gt;= prob_stop else 'B' if  p_best_B &gt;= prob_stop else 'C' if p_best_C &gt;= prob_stop else None         if best_gr:             cmp.at[i, 'A_exp'] = post_dist_A.mean()             cmp.at[i, 'B_exp'] = post_dist_B.mean()             cmp.at[i, 'C_exp'] = post_dist_C.mean()             cmp.at[i, 'exp_samp_size'] = n_samp_total             cmp.at[i, 'best_exp'] = best_gr             cmp.at[i, 'p_best'] = max(p_best_A, p_best_B, p_best_C)             break     print(f'done {i}: nsamp {n_samp_total}, best_gr {best_gr}, P_best {max(p_best_A, p_best_B, p_best_C)}')  cmp['correct'] = cmp['best_exact'] == cmp['best_exp'] display(cmp.head(20)) cor_guess = np.sum(cmp['correct']) print(f\"Nexp: {nexps}, Correct Guesses: {cor_guess}, Accuracy: {cor_guess \/ nexps}\")<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<\/div>\n<\/details>\n<p>\u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d \u043a \u0410\/\u0411-\u0442\u0435\u0441\u0442\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0441\u0438\u0439 \u0441 3 \u0433\u0440\u0443\u043f\u043f\u0430\u043c\u0438. \u041b\u0443\u0447\u0448\u0430\u044f \u0433\u0440\u0443\u043f\u043f\u0430 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439. \u0421\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432.<\/p>\n<p><strong>\u0421\u0441\u044b\u043b\u043a\u0438<\/strong>:<\/p>\n<p>[BayesABConv] &#8212; <a href=\"https:\/\/nbviewer.org\/github\/andrewbrdk\/Bayesian-AB-Testing\/blob\/main\/%D0%91%D0%B0%D0%B9%D0%B5%D1%81%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F_%D0%BE%D1%86%D0%B5%D0%BD%D0%BA%D0%B0_%D0%90%D0%91-%D1%82%D0%B5%D1%81%D1%82%D0%BE%D0%B2.ipynb#%D0%9A%D0%BE%D0%BD%D0%B2%D0%B5%D1%80%D1%81%D0%B8%D0%B8\" rel=\"noopener noreferrer nofollow\">Bayesian A\/B-Testing<\/a>, <em>GitHub.<\/em><br \/>[BetaDist] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Beta_distribution\" rel=\"noopener noreferrer nofollow\">Beta Distribution<\/a>, <em>Wikipedia.<\/em><br \/>[Bonf] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bonferroni_correction\" rel=\"noopener noreferrer nofollow\">Bonferroni Correction<\/a>, <em>Wikipedia.<\/em><br \/>[ConjPrior] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Conjugate_prior\" rel=\"noopener noreferrer nofollow\">Conjugate Prior<\/a>, <em>Wikipedia.<\/em><br \/>[FWER] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Family-wise_error_rate\" rel=\"noopener noreferrer nofollow\">Family-wise Error Rate<\/a>, <em>Wikipedia.<\/em><br \/>[MultipleComp] &#8212; <a href=\"https:\/\/en.wikipedia.org\/wiki\/Multiple_comparisons_problem\" rel=\"noopener noreferrer nofollow\">Multiple Comparisons Problem<\/a>, <em>Wikipedia.<\/em><br \/>[SciPyBeta] &#8212; <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.stats.beta.html\" rel=\"noopener noreferrer nofollow\">scipy.stats.beta<\/a>, <em>SciPy Reference.<\/em><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/903820\/\"> https:\/\/habr.com\/ru\/articles\/903820\/<\/a><br \/><\/br><\/br><\/p>\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-457301","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457301","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=457301"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/457301\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=457301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=457301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=457301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}