{"id":170633,"date":"2013-02-26T12:30:06","date_gmt":"2013-02-26T08:30:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=170633"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=170633","title":{"rendered":"<span class=\"post_title\">\u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u0432 Python<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u043e \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/170545\/\">\u0442\u0443\u0442<\/a>.<br \/>  \u042f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0434\u043b\u044f \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044f\u0437\u044b\u043a <a href=\"http:\/\/www.r-project.org\/\">R<\/a> \u0441 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 <a href=\"http:\/\/mcmc-jags.sourceforge.net\/\">JAGS<\/a> \u0438\/\u0438\u043b\u0438 <a href=\"http:\/\/www.openbugs.info\/w\/\">BUGS<\/a>. \u0414\u043b\u044f \u0440\u044f\u0434\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0435 \u0432 \u043f\u0430\u043a\u0435\u0442\u0430\u0445 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043a\u0440\u043e\u0441\u0441-\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u043e\u0441\u0442\u0438 JAGS (\u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c \u043e\u043f\u044b\u0442\u0435 \u0443\u0431\u0435\u0434\u0438\u043b\u0441\u044f \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 Ubuntu \u0438 BUGS), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 JAGS \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f (\u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u0443 \u0440\u044f\u0434\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u043d\u0435\u0447\u0430\u0441\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442). \u041a\u0441\u0442\u0430\u0442\u0438, \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c IDE \u0434\u043b\u044f R \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"http:\/\/www.rstudio.com\/\">RStudio<\/a>.<br \/>  \u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u043e\u0431 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0435 R \u2014 Python \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c <a href=\"http:\/\/pymc-devs.github.com\/pymc\/\">pymc<\/a>. <br \/>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e IDE \u0434\u043b\u044f Python \u043c\u043e\u0433\u0443 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c <a href=\"http:\/\/code.google.com\/p\/spyderlib\/\">spyder<\/a>.<br \/>  \u042f \u043e\u0442\u0434\u0430\u044e \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0435 Python \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0435 \u0432\u0438\u0436\u0443 \u0441\u043c\u044b\u0441\u043b\u0430 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a, \u043a\u0430\u043a R, \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u043a\u0443, \u043a\u0430\u0441\u0430\u044e\u0449\u0443\u044e\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, Python \u0441 \u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438, \u0441 \u043c\u043e\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u043d\u0438\u0447\u0435\u043c \u043d\u0435 \u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 R \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u042f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u0445 \u0437\u043d\u0430\u043d\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u043e\u043d\u0430 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u0430. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u041f\u041e<\/h4>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <a href=\"http:\/\/www.python.org\/download\/\">Python<\/a> (\u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0435\u0449\u0435 \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u043b). \u042f \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f Python 3.3, \u043d\u043e \u0441 2.7 \u0432\u0441\u0435 \u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<br \/>  \u0417\u0430\u0442\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0434\u043b\u044f Python: <a href=\"http:\/\/www.scipy.org\/NumPy\">numpy<\/a>, <a href=\"http:\/\/matplotlib.org\/\">Matplotlib<\/a>.<br \/>  \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438: <a href=\"http:\/\/www.scipy.org\/\">scipy<\/a>, <a href=\"http:\/\/www.pytables.org\/moin\">pyTables<\/a>, <a href=\"http:\/\/code.google.com\/p\/pydot\/\">pydot<\/a>, <a href=\"http:\/\/ipython.org\/\">IPython<\/a> \u0438 <a href=\"https:\/\/nose.readthedocs.org\/en\/latest\/\">nose<\/a>.<br \/>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 (\u043a\u0440\u043e\u043c\u0435 \u0441\u0430\u043c\u043e\u0433\u043e Python) \u043f\u0440\u043e\u0449\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/pypi.python.org\/pypi\/setuptools\">setuptools<\/a>.<br \/>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e <a href=\"https:\/\/github.com\/pymc-devs\/pymc\">pymc<\/a> (\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 setuptools).<\/p>\n<p>  \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0439 \u0433\u0430\u0439\u0434 \u043f\u043e pymc \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"http:\/\/pymc-devs.github.com\/pymc\/\">\u0442\u0443\u0442<\/a>.<\/p>\n<h4>\u0424\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h4>\n<p>  \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 \u0445\u043e\u0434\u0435 \u0433\u0438\u043f\u043e\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b x. \u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0441 \u0448\u0443\u043c\u043e\u043c, \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u0421\u043f\u0435\u0440\u0432\u0430 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438, \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f:<\/p>\n<pre><code class=\"python\">import numpy   import pymc <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c, \u043a\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0438\u043c\u0435\u0442\u044c (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 20), \u043e\u043d\u0438 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u0435 [0, 10], \u0438 \u0437\u0430\u0434\u0430\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u0433\u0430\u0443\u0441\u0441\u043e\u0432 \u0448\u0443\u043c:<\/p>\n<pre><code class=\"python\">#Generate data with noise number_points     = 20 true_coefficients = [10.4, 5.5] x                 = numpy.linspace(0, 10, number_points) noise             = numpy.random.normal(size = number_points) data              = true_coefficients[0]*x + true_coefficients[1] + noise <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437. <br \/>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u0437\u043d\u0430\u0435\u043c (\u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c), \u0447\u0442\u043e \u043d\u0430\u0448 \u0448\u0443\u043c \u0433\u0430\u0443\u0441\u0441\u043e\u0432, \u0437\u043d\u0430\u0447\u0438\u0442, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0430. \u0423 \u043d\u0435\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0438 \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f. \u0422\u0430\u043a \u043a\u0430\u043a \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0448\u0443\u043c\u0430 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e, \u0442\u043e \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 (\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0443 \u043d\u0430\u0441 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0430\u043c \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430). \u0422\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044f \u043d\u0430\u043c \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0435 \u043e\u0434\u043d\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c.<br \/>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0438 \u0433\u0430\u0443\u0441\u0441\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f.<br \/>  \u041c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 a priori \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0438\u0445 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u043c\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 (\u044d\u0442\u0438 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043e\u0434\u0432\u0438\u0433\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e).<br \/>  \u041f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u0438 \u0430\u043f\u0440\u0438\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u0435\u0442\u043a\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0443\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u043e\u0431 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f (\u0432\u0442\u043e\u0440\u043e\u0439 \u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b). \u0412\u0441\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 (\u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438).<\/p>\n<pre><code class=\"python\">sigma = pymc.Uniform('sigma', 0., 100.) a     = pymc.Uniform('a', 0., 20.) b     = pymc.Uniform('b', 0., 20.) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c. \u0412 pymc \u0441\u0443\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430: \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435(-\u044f), \u043a\u043e\u0442\u043e\u0440\u043e\u0435(-\u044b\u0435) \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442, \u0437\u043d\u0430\u0447\u0438\u0442, \u044d\u0442\u043e \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u0430\u0445 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code class=\"python\">@pymc.deterministic(plot=False) def linear_fit(a=a, b=b, x=x):       return a*x + b <\/code><\/pre>\n<p>  \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, sigma \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0430\u043f\u0440\u0438\u043e\u0440\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c, \u0430 data \u2014 \u044d\u0442\u043e \u043d\u0430\u0448\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"python\">y = pymc.Normal('y', mu=linear_fit, tau=1.0\/sigma**2, value=data, observed=True) <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u0435\u0441\u044c \u0444\u0430\u0439\u043b model.py \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\">import numpy   import pymc  #Generate data with noise number_points     = 20 true_coefficients = [10.4, 5.5] x                 = numpy.linspace(0, 10, number_points) noise             = numpy.random.normal(size = number_points) data              = true_coefficients[0]*x + true_coefficients[1] + noise  #PRIORs: #as sigma is unknown then we define it as a parameter: sigma = pymc.Uniform('sigma', 0., 100.) #fitting the line y = a*x+b, hence the coefficient are parameters: a     = pymc.Uniform('a', 0., 20.) b     = pymc.Uniform('b', 0., 20.)  #define the model: if a, b and x are given the return value is determined, hence the model is deterministic:  @pymc.deterministic(plot=False) def linear_fit(a=a, b=b, x=x):       return a*x + b  #LIKELIHOOD #normal likelihood with observed data (with noise), model value and sigma      y = pymc.Normal('y', mu=linear_fit, tau=1.0\/sigma**2, value=data, observed=True) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0434\u0435\u043b\u0430\u0435\u0442 pymc.<\/p>\n<p>  \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0435\u043c\u0435\u0442\u0438\u043a\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443:<br \/>  p(a, b, sigma | Data) = p(Data | a, b, sigma)*p(a, b, sigma) \/ p(Data)<\/p>\n<p>  \u0422.\u043a. a, b \u0438 sigma \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435:<br \/>  p(a, b, sigma | Data) = p(Data | a, b, sigma)*p(a)*p( b)*p(sigma) \/ p(Data)<\/p>\n<p>  \u041d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0435\u0435 \u0440\u0435\u0448\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e (\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0443\u043c\u0430\u0442\u044c \u0435\u0449\u0435 \u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439), \u0442\u043e \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  p(Data) \u2014 \u044d\u0442\u043e, \u043a\u0430\u043a \u043e\u0431\u0441\u0443\u0436\u0434\u0430\u043b\u043e\u0441\u044c \u0432 \u043c\u043e\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/post\/170545\/\">\u043f\u043e\u0441\u0442\u0435<\/a>, \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430. <br \/>  p(Data | a, b, sigma) \u043d\u0430\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 a, b \u0438 sigma \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0445)<br \/>  a \u0432\u043e\u0442 \u0432\u043c\u0435\u0441\u0442\u043e p(a), p( b) \u0438 p(sigma) \u0443 \u043d\u0430\u0441, \u043f\u043e \u0441\u0443\u0442\u0438, \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043f\u0441\u0435\u0432\u0434\u043e\u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0430\u043c\u0438 \u0437\u0430\u043a\u043e\u043d\u0443.<br \/>  \u041a\u0430\u043a \u0438\u0437 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \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\u0435? \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c (\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443) a, b \u0438 sigma, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c p(Data | a, b, sigma). \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 \u0438\u0437 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u041d\u043e \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u0443 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u0448\u0435 \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\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434 (\u00ab\u0445\u043e\u043b\u043c\u043e\u0432\u00bb) \u2014 \u0442\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0432\u0441\u0435 \u043c\u043e\u0434\u044b. \u0422\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430 \u0432 \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b \u00ab\u043f\u043e\u043a\u0440\u044b\u0432\u0430\u043b\u0430\u00bb \u0432\u0441\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0437\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 <a href=\"http:\/\/en.wikipedia.org\/wiki\/Markov_chain_Monte_Carlo\">MCMC<\/a> (Markov chain Monte Carlo). <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%A6%D0%B5%D0%BF%D1%8C_%D0%9C%D0%B0%D1%80%D0%BA%D0%BE%D0%B2%D0%B0\">\u0426\u0435\u043f\u044c \u041c\u0430\u0440\u043a\u043e\u0432\u0430<\/a> \u2014 \u044d\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u0436\u0434\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e, \u043d\u043e \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u0440\u0435\u0434\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e. \u042f \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c (\u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0435\u043c\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430), \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e pymc \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u0430\u0435\u0442 \u0446\u0435\u043f\u044c \u041c\u0430\u0440\u043a\u043e\u0432\u0430, \u044f\u0432\u043b\u044f\u044e\u0449\u0443\u044e\u0441\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 \u0438\u0437 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u0412\u043e\u043e\u0431\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0441\u043b\u0438 \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0446\u0435\u043f\u044c \u0431\u044b\u043b\u0430 \u043c\u0430\u0440\u043a\u043e\u0432\u0441\u043a\u043e\u0439, \u0442\u043e \u043d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0434\u043e \u0435\u0435 \u00ab\u0443\u0442\u043e\u043d\u044c\u0448\u0438\u0442\u044c\u00bb, \u0442.\u0435. \u0431\u0440\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<br \/>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0444\u0430\u0439\u043b, \u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e run_model.py, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043f\u044c \u041c\u0430\u0440\u043a\u043e\u0432\u0430. \u0424\u0430\u0439\u043b\u044b model.py \u0438 run_model.py \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435, \u0438\u043d\u0430\u0447\u0435, \u0432 \u0444\u0430\u0439\u043b run_model.py \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"python\">from sys import path path.append(&quot;\u043f\u0443\u0442\u044c\/\u043a\/\u043f\u0430\u043f\u043a\u0435\/\u0441\/\u0444\u0430\u0439\u043b\u043e\u043c\/model.py\/&quot;) <\/code><\/pre>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f:<\/p>\n<pre><code class=\"python\">from numpy             import polyfit from matplotlib.pyplot import figure, plot, show, legend import pymc import model <\/code><\/pre>\n<p>  polyfit \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u2014 \u0441 \u043d\u0438\u043c \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0431\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<br \/>  figure, plot, show, legend \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a.<br \/>  model \u2014 \u044d\u0442\u043e, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c MCMC \u043e\u0431\u044a\u0435\u043a\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0443:<\/p>\n<pre><code class=\"python\">D = pymc.MCMC(model, db = 'pickle') D.sample(iter = 10000, burn = 1000) <\/code><\/pre>\n<p>   D.sample \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 (\u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435) \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 burn-in (\u043d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e \u00ab\u043f\u0435\u0440\u0438\u043e\u0434\u043e\u043c \u0440\u0430\u0437\u043e\u0433\u0440\u0435\u0432\u0430\u00bb). \u041f\u0435\u0440\u0438\u043e\u0434 \u0440\u0430\u0437\u043e\u0433\u0440\u0435\u0432\u0430 \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u0440\u0435\u0437\u0430\u044e\u0442\u0441\u044f. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e MCMC \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 (\u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 \u0443\u0436 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u0440\u0435\u0437\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0435\u0440\u0438\u043e\u0434 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0448 \u0430\u043d\u0430\u043b\u0438\u0437 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 D, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430, \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (\u0444\u0443\u043d\u043a\u0446\u0438\u0438), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u044d\u0442\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 (\u0441\u0440\u0435\u0434\u043d\u0435\u0435, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0434\u0438\u0441\u043f\u0435\u0440\u0441\u0438\u044e \u0438 \u043f\u0440.).<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432: <\/p>\n<pre><code class=\"python\">chisq_result = polyfit(model.x, model.data, 1) <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0432\u0441\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b:<\/p>\n<pre><code class=\"python\">print &quot;\\n\\nResult of chi-square result: a= %f, b= %f&quot; % (chisq_result[0], chisq_result[1]) print &quot;\\nResult of Bayesian analysis: a= %f, b= %f&quot; % (D.a.value, D.b.value) print &quot;\\nThe real coefficients are:   a= %f, b= %f\\n&quot; %(model.true_coefficients[0], model.true_coefficients[1]) <\/code><\/pre>\n<p>  \u0421\u0442\u0440\u043e\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0434\u043b\u044f pymc \u0433\u0440\u0430\u0444\u0438\u043a\u0438:<\/p>\n<pre><code class=\"python\">pymc.Matplot.plot(D) <\/code><\/pre>\n<p>  \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u0442\u0440\u043e\u0438\u043c \u043d\u0430\u0448 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a:<\/p>\n<pre><code class=\"python\">figure() plot(model.x, model.data, marker='+', linestyle='') plot(model.x, D.a.value * model.x + D.b.value, color='g', label='Bayes') plot(model.x, chisq_result[0] * model.x + chisq_result[1], color='r', label='Chi-squared') plot(model.x, model.true_coefficients[0] * model.x + model.true_coefficients[1], color='k', label='Data') legend() show() <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 run_model.py:<\/p>\n<pre><code class=\"python\">from numpy             import polyfit from matplotlib.pyplot import figure, plot, show, legend import pymc import model  #Define MCMC: D = pymc.MCMC(model, db = 'pickle')  #Sample MCMC: 10000 iterations, burn-in period is 1000 D.sample(iter = 10000, burn = 1000)   #compute chi-squared fitting for comparison: chisq_result = polyfit(model.x, model.data, 1)  #print the results: print &quot;\\n\\nResult of chi-square result: a= %f, b= %f&quot; % (chisq_result[0], chisq_result[1]) print &quot;\\nResult of Bayesian analysis: a= %f, b= %f&quot; % (D.a.value, D.b.value) print &quot;\\nThe real coefficients are:   a= %f, b= %f\\n&quot; %(model.true_coefficients[0], model.true_coefficients[1])  #plot graphs from MCMC: pymc.Matplot.plot(D)  #plot noised data, true line and two fitted lines (bayes and chi-squared): figure() plot(model.x, model.data, marker='+', linestyle='') plot(model.x, D.a.value * model.x + D.b.value, color='g', label='Bayes') plot(model.x, chisq_result[0] * model.x + chisq_result[1], color='r', label='Chi-squared') plot(model.x, model.true_coefficients[0] * model.x + model.true_coefficients[1], color='k', label='Data') legend() show() <\/code><\/pre>\n<p>  \u0412 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0442\u0432\u0435\u0442:<\/p>\n<p>  Result of chi-square result: a= 10.321533, b= 6.307100<\/p>\n<p>  Result of Bayesian analysis: a= 10.366272, b= 6.068982<\/p>\n<p>  The real coefficients are: a= 10.400000, b= 5.500000<\/p>\n<p>  \u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0438\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u043e \u0441\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c, \u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0443 \u0441\u0435\u0431\u044f, \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 (\u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438).<\/p>\n<p>  \u0410 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c run_model.py \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438.<br \/>  \u0414\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 a:<br \/>  <img decoding=\"async\" src=\"http:\/\/s2.hostingkartinok.com\/uploads\/images\/2013\/02\/9fa8ec600d2e44f3e1d12e8caaa5d0ca.png\" alt=\"image\"\/><br \/>  \u0414\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 b:<br \/>  <img decoding=\"async\" src=\"http:\/\/s2.hostingkartinok.com\/uploads\/images\/2013\/02\/8fff37f492f756d4f19e9095734d9f33.png\" alt=\"image\"\/><br \/>  \u0414\u043b\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 sigma:<br \/>  <img decoding=\"async\" src=\"http:\/\/s2.hostingkartinok.com\/uploads\/images\/2013\/02\/3f5e9b1795e0d04ffce1cc56ffb58405.png\" alt=\"image\"\/><br \/>  \u0421\u043f\u0440\u0430\u0432\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0430\u043f\u043e\u0441\u0442\u0435\u0440\u0438\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u0430 \u0434\u0432\u0435 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441\u043b\u0435\u0432\u0430 \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0446\u0435\u043f\u0438 \u041c\u0430\u0440\u043a\u043e\u0432\u0430.<br \/>  \u041d\u0430 \u043d\u0438\u0445 \u044f \u0441\u0435\u0439\u0447\u0430\u0441 \u0437\u0430\u043e\u0441\u0442\u0440\u044f\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443. \u0421\u043a\u0430\u0436\u0443 \u043b\u0438\u0448\u044c, \u0447\u0442\u043e \u043d\u0438\u0436\u043d\u0438\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u2014 \u044d\u0442\u043e \u0433\u0440\u0430\u0444\u0438\u043a \u0430\u0432\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043b\u044f\u0446\u0438\u0438 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/pymc-devs.github.com\/pymc\/modelchecking.html#convergence-diagnostics\">\u0442\u0443\u0442<\/a>). \u041e\u043d \u0434\u0430\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 MCMC.<br \/>  \u0410 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u0435\u0434 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u043b\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0441 \u0442\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0421\u0440\u0435\u0434\u043d\u0435\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0430 \u0435\u0441\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 (\u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u043e\u0441\u044c \u043d\u0430 \u044d\u0442\u043e\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0441 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0441\u044c\u044e \u043d\u0430 \u0433\u0438\u0441\u0442\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0441\u043f\u0440\u0430\u0432\u0430).<\/p>\n<p>  \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u0435\u0449\u0435 \u043e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u043e\u043f\u0446\u0438\u0438.<br \/>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0436\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 pydot \u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 run_model.py \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code class=\"python\">pymc.graph.dag(D).write_png('dag.png') <\/code><\/pre>\n<p>  \u0422\u043e \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0432 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c run_model.py \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/s4.hostingkartinok.com\/uploads\/images\/2013\/02\/cdafb476a14e421800f347c7bff2ba93.png\" alt=\"image\"\/><\/p>\n<p>  \u042d\u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0439 \u0430\u0446\u0438\u043a\u043b\u0438\u0447\u043d\u044b\u0439 \u0433\u0440\u0430\u0444, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c. \u0411\u0435\u043b\u044b\u0435 \u044d\u043b\u043b\u0438\u043f\u0441\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0437\u043b\u044b (\u044d\u0442\u043e a, b \u0438 sigma), \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u2014 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0437\u043b\u044b, \u0430 \u0437\u0430\u0442\u0435\u043c\u043d\u0435\u043d\u043d\u044b\u0439 \u044d\u043b\u043b\u0438\u043f\u0441 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043d\u0430\u0448\u0438 \u043f\u0441\u0435\u0432\u0434\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>  \u0422\u043e \u0435\u0441\u0442\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0430\u043d\u0438\u044f a \u0438 b \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c (linear_fit), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0441\u0442\u0441\u043a\u0438\u043c \u0443\u0437\u043b\u043e\u043c, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f y. Sigma \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0443\u0437\u043b\u043e\u043c, \u043d\u043e \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 sigma, \u0430 tau = 1\/sigma^2, \u0442\u043e \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 sigma \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u043e\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 (\u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0441\u043f\u0440\u0430\u0432\u0430), \u0438 \u043f\u043e\u0442\u043e\u043c \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f tau. \u0418 \u0443\u0436\u0435 tau \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u0438\u044f, \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u043d\u0430\u0448\u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<br \/>  \u042f \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0433\u0440\u0430\u0444 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u043a\u0430\u043a \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043b\u043e\u0433\u0438\u043a\u0438<br \/>  \u043c\u043e\u0434\u0435\u043b\u0438.    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/170633\/\"> http:\/\/habrahabr.ru\/post\/170633\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u042d\u0442\u043e\u0442 \u043f\u043e\u0441\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430 \u043e \u0411\u0430\u0439\u0435\u0441\u043e\u0432\u0441\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/170545\/\">\u0442\u0443\u0442<\/a>.<br \/>  \u042f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.  <\/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-170633","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/170633","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=170633"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/170633\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=170633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=170633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=170633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}