{"id":272231,"date":"2016-01-16T01:59:01","date_gmt":"2016-01-15T22:59:01","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=272231"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=272231","title":{"rendered":"\u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d"},"content":{"rendered":"<p>       \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u0442\u0430 <a href=\"http:\/\/habrahabr.ru\/post\/263993\/\"> \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u0434\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u0439, \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b. \u041a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435, \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 0 \u0434\u043e RAND_MAX:<\/p>\n<pre><code>unsigned long long BasicRandGenerator() {     unsigned long long randomVariable;     \/\/ some magic here     ...     return randomVariable; } <\/code><\/pre>\n<p>  \u0421 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430\u043c\u0438 \u0432\u0441\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/99e\/65a\/4a5\/99e65a4a51ed4235aa4e234029198627.png\" \/><\/div>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u0447\u0430\u0441 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043d\u0435\u0436\u0435\u043b\u0438 \u0447\u0435\u043c \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0435. \u041d\u0430\u0447\u043d\u0435\u043c, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u0441 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<h4><font color=\"#089\">\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/594\/995\/aef\/594995aef57c42a597c5c2770afcf282.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/792\/3a5\/cb7\/7923a5cb7e36429cacaad61739956285.png\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0438\u0437 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438 \u2014 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u0432\u0441\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 double \u043b\u0438\u0448\u044c \u0434\u043b\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430):<\/p>\n<pre><code>void setup(double p) {     unsigned long long boundary = (1 - p) * RAND_MAX; \/\/ we storage this value for large sampling }  double Bernoulli(double) {     return BasicRandGenerator() &gt; boundary; } <\/code><\/pre>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u00ab\u0418\u043d\u043e\u0433\u0434\u0430\u00bb \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 p \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e 1\/2\u00bb. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 BasicRandGenerator() \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u043e\u0439, \u0442\u043e \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0435\u0433\u043e \u0431\u0438\u0442. \u0410 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u043e \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0431\u0438\u0442\u043e\u0432, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 unsigned long long, \u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c 64 \u0431\u0438\u0442\u0430. \u0412\u043e\u0442 \u043a\u0430\u043a\u043e\u0439 \u0442\u0440\u044e\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0434\u043b\u044f p = 1\/2:<\/p>\n<pre><code>double Bernoulli(double) {     static const char maxDecimals = 64;     static char decimals = 1;     static unsigned long long X = 0;     if (decimals == 1)     {         \/\/\/ refresh         decimals = maxDecimals;         X = BasicRandGenerator();     }     else     {         --decimals;         X &gt;&gt;= 1;     }     return X & 1; } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 BasicRandGenerator() \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u043e, \u0430 \u043a\u0440\u0438\u043f\u0442\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c\u044e \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u0430 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0447\u044c, \u0442\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0443 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438:<\/p>\n<pre><code>void setup(double p) {     q = 1.0 - p;     U = Uniform(0, 1); }  double Bernoulli(double p) {     if (U &gt; q)     {         U -= q;         U \/= p;         return 1.0;     }     U \/= q;     return 0.0; } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442?<\/b><\/p>\n<div class=\"spoiler_text\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b58\/624\/591\/b5862459180b4fd197b65e5b78d7f2b3.png\" \/><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f96\/acd\/832\/f96acd832ac2415db05edab4eef37014.png\" \/><\/div>\n<p>  <\/div>\n<\/div>\n<h4><font color=\"#089\">\u0420\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/17e\/7e6\/a5e\/17e7e6a5e0c044e3bd0add19ba355b62.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/424\/7d1\/6f8\/4247d16f823c4a12bd6b16409cf41c30.png\"\/><\/p>\n<p>  \u0423\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u0432\u0430\u0441 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442, \u0447\u0442\u043e \u0435\u0433\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u043e\u0442 a \u0434\u043e b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043d\u0430 \u044d\u0442\u043e:<\/p>\n<pre><code>double UniformDiscrete(int a, int b) {     return a + rand() % (b - a + 1); } <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0436, \u0438 \u044d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0421 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0435\u0440\u043d\u044b\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u2014 \u0443 \u0432\u0430\u0441 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u043d \u0434\u0435\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043a\u0430\u043a \u0441\u0442\u0430\u0440\u044b\u0439 \u0421-\u0448\u043d\u044b\u0439 rand(), \u0442\u043e \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0447\u0435\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0437\u0430 \u043d\u0435\u0447\u0435\u0442\u043d\u044b\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0434\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0435 \u0441\u0432\u043e\u0435\u043c\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0443, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0430\u043a:<\/p>\n<pre><code>double UniformDiscrete(int a, int b) {     return a + round(BasicRandGenerator() * (b - a) \/ RAND_MAX); } <\/code><\/pre>\n<p>  \u0415\u0449\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 RAND_MAX \u043d\u0435 \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0434\u043b\u0438\u043d\u0443 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 b \u2014 a + 1 \u043d\u0430\u0446\u0435\u043b\u043e. \u041e\u0434\u043d\u0430\u043a\u043e, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0437\u043d\u0430\u0447\u0438\u043c\u0430, \u0435\u0441\u043b\u0438 \u044d\u0442\u0430 \u0434\u043b\u0438\u043d\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u0430\u043b\u0430.<\/p>\n<h4><font color=\"#089\">\u0413\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e49\/155\/542\/e4915554219f4d52aa6eb7601f321dda.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/132\/0d9\/9a3\/1320d99a3b0048b2bb89f3ea13ec3dd8.png\"\/><\/p>\n<p>  \u0421\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u0441 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c p \u2014 \u044d\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u0441 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c -ln(1 \u2014 p), \u043e\u043a\u0440\u0443\u0433\u043b\u0435\u043d\u043d\u0430\u044f \u0432\u043d\u0438\u0437 \u0434\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0443\u0441\u043a\u0430\u0439 W \u2014 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c -ln(1 \u2014 p). \u0422\u043e\u0433\u0434\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4dd\/ce6\/96e\/4ddce696e19d485d8301a89310b28a82.png\" \/><\/div>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<pre><code>void setupRate(double p) {     rate = -ln(1 - p); }  double Geometric(double) {     return floor(Exponential(rate)); } <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u0435\u0435? \u0418\u043d\u043e\u0433\u0434\u0430. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b23\/6ac\/c0b\/b236acc0b05a4583aeb7ff9e4e0843fb.png\" \/><\/div>\n<p>  \u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u0438: \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u0443\u044e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 U \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 k, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044d\u0442\u0430 \u0441\u0443\u043c\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 U:<\/p>\n<pre><code>double GeometricExponential(double p) {     int k = 0;     double sum = p, prod = p, q = 1 - p;     double U = Uniform(0, 1);     while (U &lt; sum) {         prod *= q;         sum += prod;         ++k;     }     return k; } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d, \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0441 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432\u043e\u0437\u043b\u0435 \u043d\u0443\u043b\u044f. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043e\u0434\u043d\u0430\u043a\u043e, \u0431\u044b\u0441\u0442\u0440\u043e \u0442\u0435\u0440\u044f\u0435\u0442 \u0441\u0432\u043e\u044e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 p, \u0438 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435 \u0436\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c.<br \/>  \u0415\u0441\u0442\u044c \u0441\u0435\u043a\u0440\u0435\u0442. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f p, (1-p) * p, (1-p)^2 * p,\u2026 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438 \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c. \u0412\u043e\u043f\u0440\u043e\u0441 \u0432 \u0442\u043e\u043c, \u0433\u0434\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f. \u0418 \u0442\u0443\u0442 \u043d\u0430 \u0441\u0446\u0435\u043d\u0443 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u043d\u043e \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u043e\u0442 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u2014 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/744\/3a9\/b76\/7443a9b762ba48439317d5436683a37b.png\" \/><\/div>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u043a\u043e\u043c\u0443 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (1-p)^i * p \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0435\u0439:<\/p>\n<pre><code>\/\/ works nice for p &gt; 0.2 and tableSize = 16 void setupTable(double p) {     table[0] = p;     double prod = p, q = 1 - p;     for (int i = 1; i &lt; tableSize; ++i)     {         prod *= q;         table[i] = table[i - 1] + prod;     } }  double GeometricTable(double p) {     double U = Uniform(0, 1);     \/\/\/ handle tail by recursion     if (U &gt; table[tableSize - 1])         return tableSize + GeometricTable(p);     \/\/\/ handle the main body     int x = 0;     while (U &gt; table[x])         ++x;     return x; } <\/code><\/pre>\n<h4><font color=\"#089\">\u0411\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/261\/815\/4b6\/2618154b61574a3097c1e904b04004a8.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/362\/a20\/9be\/362a209be1a24fa384af9b5c4c833759.png\"\/><\/p>\n<p>  \u041f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u0441 \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 \u2014 \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 n \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438:<\/p>\n<pre><code>double BinomialBernoulli(double p, int n) {     double sum = 0;     for (int i = 0; i != n; ++i)         sum += Bernoulli(p);     return sum; } <\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 n, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438. \u041c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u043e\u0439: \u0435\u0441\u043b\u0438 Y_1, Y_2,\u2026 \u2014 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0441 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c p \u0438 X \u2014 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0446\u0435\u043b\u043e\u0435, \u0442\u0430\u043a\u043e\u0435 \u0447\u0442\u043e:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d26\/c9d\/6d3\/d26c9d6d356a499d8d2a7d3a2aee389a.png\" \/><\/div>\n<p>  \u0442\u043e X \u0438\u043c\u0435\u0435\u0442 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u0441 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c Y \u2014 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u044b\u0442\u043e\u0432 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438 \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0445\u0430. \u0415\u0441\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435: Z = Y + 1 \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u044b\u0442\u043e\u0432 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438 \u0434\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0445\u0430 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0417\u043d\u0430\u0447\u0438\u0442, \u0441\u0443\u043c\u043c\u0430 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 Z_i \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u044b\u0442\u043e\u0432 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438 \u0434\u043e X + 1 \u0443\u0441\u043f\u0435\u0445\u0430 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u0418 \u044d\u0442\u0430 \u0441\u0443\u043c\u043c\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 n \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u0441\u0440\u0435\u0434\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 n \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0439 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c X \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0445. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/842\/a22\/0f0\/842a220f063049bcba3cc3b3071e6c86.png\" \/><\/div>\n<p>  q.e.d.  <\/div>\n<\/div>\n<p>  \u0412\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u0440\u0430\u0441\u0442\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b n * p.<\/p>\n<pre><code>double BinomialGeometric(double p, int n) {     double X = -1, sum = 0;     do {         sum += Geometric(p) + 1.0;         ++X;     } while (sum &lt;= n);     return X; } <\/code><\/pre>\n<p>  \u0418 \u0432\u0441\u0435 \u0436\u0435, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0442\u0435\u0442. <br \/>  \u0423 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c. \u041f\u0440\u0438 \u0440\u043e\u0441\u0442\u0435 n \u043e\u043d\u043e \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u0438\u043b\u0438 \u0436\u0435, \u0435\u0441\u043b\u0438 p ~ 1\/n, \u0442\u043e \u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u041f\u0443\u0430\u0441\u0441\u043e\u043d\u0430. \u0418\u043c\u0435\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u043c\u043e\u0436\u043d\u043e \u0438\u043c\u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445. \u041d\u043e \u0447\u0442\u043e, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e? \u0412 \u043a\u043d\u0438\u0433\u0435 Luc Devroye \u00abNon-Uniform Random Variate Generation\u00bb \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 n * p. \u0418\u0434\u0435\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0435 \u0441 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0440\u0430\u0441\u0441\u043a\u0430\u0437 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u044d\u0442\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u043e \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0435 \u043e\u043d \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0435 \u043e\u043f\u0438\u0441\u0430\u043d.<\/p>\n<h4><font color=\"#089\">\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u041f\u0443\u0430\u0441\u0441\u043e\u043d\u0430<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e17\/cba\/d3e\/e17cbad3e4314e10983c3907ce8d15bc.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7b5\/657\/993\/7b56579932ae4300bef692441cde30fd.png\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 W_i \u2014 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0441 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e lambda, \u0442\u043e:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1a9\/96b\/c0e\/1a996bc0e7224352a5b5ffe99b684347.png\" \/><\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\u041f\u0443\u0441\u043a\u0430\u0439 f_k(y) \u2014 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u042d\u0440\u043b\u0430\u043d\u0433\u0430 (\u0441\u0443\u043c\u043c\u044b k \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/7ae\/6fd\/f29\/7ae6fdf29edf4ac69bbf41f0f10f8690.png\" \/><\/div>\n<p>  \u0442\u043e\u0433\u0434\u0430 <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/907\/a99\/8b9\/907a998b9d874cea9a3d91bff8b66065.png\" \/><\/div>\n<p>  \u0438 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c k:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/2a7\/4e9\/c73\/2a74e9c73f894fc0b34290921151efeb.png\" \/><\/div>\n<p>  \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u041f\u0443\u0430\u0441\u0441\u043e\u043d\u0430. q.e.d.  <\/div>\n<\/div>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0447\u0435\u0440\u0435\u0437 \u0441\u0443\u043c\u043c\u0443 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d \u0441 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c\u044e rate:<\/p>\n<pre><code>double PoissonExponential(double rate) {     int k = -1;     double s = 0;     do {         s += Exponential(1);         ++k;     } while (s &lt; rate);     return k; } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u0436\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041a\u043d\u0443\u0442\u0430. \u0412\u043c\u0435\u0441\u0442\u043e \u0441\u0443\u043c\u043c\u044b \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d, \u043a\u0430\u0436\u0434\u0443\u044e \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 -ln(U), \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1e9\/692\/637\/1e96926372c143c0aeaf39b155fce5c0.png\" \/><\/div>\n<p>  \u0438 \u0442\u043e\u0433\u0434\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9a6\/b83\/d5a\/9a6b83d5a9994388a5595b7cd1ea4c39.png\" \/><\/div>\n<p>  \u0417\u0430\u043f\u043e\u043c\u043d\u0438\u0432 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 exp(-rate), \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0430\u0435\u043c U_i, \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442.<\/p>\n<pre><code>void setup(double rate)     expRateInv = exp(-rate); }  double PoissonKnuth(double) {     double k = 0, prod = Uniform(0, 1);     while (prod &gt; expRateInv) {         prod *= Uniform(0, 1);         ++k;     }     return k; } <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0438 \u043c\u0435\u0442\u043e\u0434 \u0438\u043d\u0432\u0435\u0440\u0441\u0438\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/23a\/6a6\/2e5\/23a6a62e57f64899ac89aa894f01abe6.png\" \/><\/div>\n<p>  \u041f\u043e\u0438\u0441\u043a k, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0433\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u043b\u0443\u0447\u0448\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0441 floor(rate). \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c U \u0441 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c\u044e, \u0447\u0442\u043e X &lt; floor(rate) \u0438 \u0438\u0434\u0435\u043c \u0432\u0432\u0435\u0440\u0445, \u0435\u0441\u043b\u0438 U \u0431\u043e\u043b\u044c\u0448\u0435, \u0438\u043b\u0438 \u0432\u043d\u0438\u0437 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/p>\n<pre><code>void setup(double rate)     floorLambda = floor(rate);     FFloorLambda = F(floorLamda); \/\/ P(X &lt; floorLambda)     PFloorLambda = P(floorLambda); \/\/ P(X = floorLambda) }  double PoissonInversion(double) {     double U = Uniform(0,1);     int k = floorLambda;     double s = FFloorLambda, p = PFloorLambda;     if (s &lt; U) {         do {             ++k;             p *= lambda \/ k;             s += p;         } while (s &lt; U);     }     else {         s -= p;         while (s &gt; U) {             p \/= lambda \/ k;             --k;             s -= p;         }     }     return k; } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u2014 \u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u0442\u0435\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438. \u041d\u043e \u0435\u0441\u0442\u044c \u0441\u043f\u0430\u0441\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u041f\u0443\u0430\u0441\u0441\u043e\u043d\u0430 \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u0441\u044f \u043a \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e. \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0437 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043a\u043d\u0438\u0433\u0438 \u00abNon-Uniform Random Variate Generation\u00bb, \u043d\u0443, \u0438\u043b\u0438 \u0436\u0435, \u043f\u043e\u043f\u0440\u043e\u0441\u0442\u0443 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0433\u0430\u044f \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043e \u0438\u043c\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 (\u0441\u043c\u043e\u0442\u0440\u044f \u043a\u0430\u043a\u0430\u044f \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430).<\/p>\n<h4><font color=\"#089\">\u041e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/0f6\/4cf\/fcd\/0f64cffcd84941a8aa0f04b62b054a5f.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e4e\/efb\/eb0\/e4eefbeb0bf9469fa4d4e4337ad8c1af.png\"\/><\/p>\n<p>  \u041e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u0438\u043c\u0435\u043d\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u041f\u0430\u0441\u043a\u0430\u043b\u044f (\u0435\u0441\u043b\u0438 r \u0446\u0435\u043b\u043e\u0435) \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u041f\u043e\u043b\u044f (\u0435\u0441\u043b\u0438 r \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0435\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c). \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u041f\u0430\u0441\u043a\u0430\u043b\u044f \u2014 \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 r \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c 1 \u2014 p:<\/p>\n<pre><code>double Pascal(double p, int r) {     double x = 0;     for (int i = 0; i != r; ++i)         x += Geometric(1 - p);     return x; } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0442\u0430\u043a\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043d\u0430\u043b\u0438\u0446\u043e \u2014 \u043b\u0438\u043d\u0435\u0439\u043d\u0430\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 r. \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0442\u0430\u043a\u043e\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u0440\u0438 \u043b\u044e\u0431\u043e\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435. \u0418 \u0432 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e. \u0415\u0441\u043b\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 X \u0438\u043c\u0435\u0435\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u041f\u0443\u0430\u0441\u0441\u043e\u043d\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/034\/dc5\/ad9\/034dc5ad968c4e5da9f47de05bb0733d.png\" \/><\/div>\n<p>  \u0433\u0434\u0435 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430 \u0438 \u0438\u043c\u0435\u0435\u0442 \u0433\u0430\u043c\u043c\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/701\/434\/8af\/7014348af9754038a57c4803e33aced8.png\" \/><\/div>\n<p>  \u0442\u043e X \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043e\u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0433\u0430\u043c\u043c\u0430-\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u041f\u0443\u0430\u0441\u0441\u043e\u043d\u0430.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/758\/e85\/9a9\/758e859a9b3d48a2a12c88689b4825c5.png\" \/><\/div>\n<p>  <\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u041f\u0430\u0441\u043a\u0430\u043b\u044f \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 r. <\/p>\n<pre><code>double Pascal(double p, int r) {     return Poisson(Gamma(r, p \/ (1 - p))); } <\/code><\/pre>\n<h4><font color=\"#089\">\u0413\u0438\u043f\u0435\u0440\u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/83a\/154\/d0f\/83a154d0f6c8490e8cab2e895e28645d.png\" \/><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/559\/598\/597\/559598597ca64dbaa54e538478634c7b.png\" \/><\/div>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0432 \u0443\u0440\u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f N \u0448\u0430\u0440\u043e\u0432 \u0438 K \u0438\u0437 \u043d\u0438\u0445 \u0431\u0435\u043b\u044b\u0435. \u0412\u044b \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u0442\u0435 n \u0448\u0430\u0440\u043e\u0432. \u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0431\u0435\u043b\u044b\u0445 \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0433\u0438\u043f\u0435\u0440\u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043b\u0443\u0447\u0448\u0435 \u0431\u0440\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>double HyperGeometric(int N, int n, int K) {     int sum = 0;     double realK = static_cast&lt;double&gt;(K);     double p = realK \/ N;     for (int i = 1; i &lt;= n; ++i)     {         if (Bernoulli(p) && ++sum == K)             return sum;         p = (realK - sum) \/ (N - i);     }     return sum; } <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 \u0441 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/abb\/f41\/a17\/abbf41a175ac4dfba28858c1a0d77408.png\" \/><\/div>\n<p>  \u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439 \u041c:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ebf\/6bc\/472\/ebf6bc472d3941e993a2932d31280c9c.png\" \/><\/div>\n<p>  \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441 \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 \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u044d\u043a\u0441\u0442\u0440\u0435\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 n \u0438 \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 N (\u0442\u0430\u043a\u0438\u0445, \u0447\u0442\u043e n &lt;&lt; N). \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u2014 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0435\u0433\u043e \u0440\u0430\u0441\u0442\u0443\u0449\u0443\u044e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432.<\/p>\n<h4><font color=\"#089\">\u041b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/24c\/8b3\/ee3\/24c8b3ee3215449e8d480b619e8709b8.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/723\/d1f\/72b\/723d1f72bc93492fa87fc03928a4dc04.png\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0442\u0435\u043e\u0440\u0435\u043c\u0430. \u0415\u0441\u043b\u0438 U \u0438 V \u2014 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u043e\u0442 0 \u0434\u043e 1, \u0442\u043e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d86\/562\/ae1\/d86562ae14504011a577f64b6f286a3e.png\" \/><\/div>\n<p>  \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\u0412\u0441\u043f\u043e\u043c\u043d\u0438\u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e X, \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0443\u043b\u043e\u0439 \u0432\u044b\u0448\u0435, \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e8b\/9b6\/e99\/e8b9b6e99b53427897627aed86ff540c.png\" \/><\/div>\n<p>  \u0414\u043e\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e X \u0438\u043c\u0435\u0435\u0442 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/482\/8aa\/712\/4828aa7122df4de695d7c8e37e162652.png\" \/><\/div>\n<p>  q.e.d.  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0432\u0443\u043c\u044f \u0443\u043b\u043e\u0432\u043a\u0430\u043c\u0438. \u041f\u0435\u0440\u0432\u0430\u044f: \u0435\u0441\u043b\u0438 V &gt; p, \u0442\u043e X = 1, \u0442.\u043a. p &gt;= 1-(1-p)^U. \u0412\u0442\u043e\u0440\u0430\u044f: \u043f\u0443\u0441\u043a\u0430\u0439 q = 1-(1-p)^U, \u0442\u043e\u0433\u0434\u0430 \u0435\u0441\u043b\u0438 V &gt; q, \u0442\u043e X = 1, \u0435\u0441\u043b\u0438 V &gt; q^2, \u0442\u043e X = 2 \u0438 \u0442.\u0434. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 1 \u0438 2 \u0431\u0435\u0437 \u0447\u0430\u0441\u0442\u044b\u0445 \u043f\u043e\u0434\u0441\u0447\u0435\u0442\u043e\u0432 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u043e\u0432.<\/p>\n<pre><code>void setup(double p) {     logQInv = 1.0 \/ log(1.0 - p); }  double Logarithmic(double p) {     double V = Uniform(0, 1);     if (V &gt;= p)         return 1.0;     double U = Uniform(0, 1);     double y = 1.0 - exp(U \/ logQInv);     if (V &gt; y)         return 1.0;     if (V &lt;= y * y)         return floor(1.0 + log(V) \/ log(y));     return 2.0; } <\/code><\/pre>\n<h4><font color=\"#089\">\u0417\u0435\u0442\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/be4\/534\/640\/be4534640928488294915f54a3460bac.png\" \/><\/div>\n<p>  \u0412 \u0437\u043d\u0430\u043c\u0435\u043d\u0430\u0442\u0435\u043b\u0435 \u2014 \u0437\u0435\u0442\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0420\u0438\u043c\u0430\u043d\u0430:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/89f\/ac3\/841\/89fac38416a343dca149dc83388cc7eb.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/39a\/17d\/4bb\/39a17d4bb3894bb8b27c18f4c8e548b0.png\"\/><\/p>\n<p>  \u0414\u043b\u044f \u0437\u0435\u0442\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0440\u0438\u043c\u0430\u043d\u043e\u0432\u0441\u043a\u0443\u044e \u0437\u0435\u0442\u0430-\u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0443\u043c\u0435\u0442\u044c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u041f\u0430\u0440\u0435\u0442\u043e. \u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u043c\u043e\u0433\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u043e \u043f\u0440\u043e\u0441\u044c\u0431\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<pre><code>void setup(double s) {     double sm1 = s - 1.0;     b = 1 - pow(2.0, -sm1); }  double Zeta(double) {     \/\/\/ rejection sampling from rounded down Pareto distribution     int iter = 0;     do {         double X = floor(Pareto(sm1, 1.0));         double T = pow(1.0 + 1.0 \/ X, sm1);         double V = Uniform(0, 1);         if (V * X * (T - 1) &lt;= T * b)             return X;     } while (++iter &lt; 1e9);     return NAN; \/\/\/ doesn't work } <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0447\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439:<\/p>\n<pre><code>double Skellam(double m1, double m2) {     return Poisson(m1) - Poisson(m2); }  double Planck(double a, double b) {     double G = Gamma(a + 1, 1);     double Z = Zeta(a + 1)     return G \/ (b * Z); }  double Yule(double ro) {     double prob = 1.0 \/ Pareto(ro, 1.0);     return Geometric(prob) + 1; } <\/code><\/pre>\n<div class=\"clear\"><\/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\/265321\/\"> http:\/\/habrahabr.ru\/post\/265321\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u0442\u0430 <a href=\"http:\/\/habrahabr.ru\/post\/263993\/\"> \u0413\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d<\/a>. \u0412 \u044d\u0442\u043e\u0439 \u0433\u043b\u0430\u0432\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0442\u0435\u043e\u0440\u0435\u043c\u044b \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u0434\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0435\u0439, \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b. \u041a\u0430\u043a \u0438 \u0440\u0430\u043d\u0435\u0435, \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u043e\u0442 0 \u0434\u043e RAND_MAX:<\/p>\n<pre><code>unsigned long long BasicRandGenerator() {     unsigned long long randomVariable;     \/\/ some magic here     ...     return randomVariable; } <\/code><\/pre>\n<p>  \u0421 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u044b\u043c\u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430\u043c\u0438 \u0432\u0441\u0435 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435. \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0439 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/99e\/65a\/4a5\/99e65a4a51ed4235aa4e234029198627.png\" \/><\/div>\n<p>  \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u0432\u0435\u043b\u0438\u0447\u0438\u043d, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043f\u043e\u0434\u0447\u0430\u0441 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043d\u0435\u0436\u0435\u043b\u0438 \u0447\u0435\u043c \u043d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u044b\u0435. \u041d\u0430\u0447\u043d\u0435\u043c, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u0441 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430.<\/p>\n<h4><font color=\"#089\">\u0420\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0411\u0435\u0440\u043d\u0443\u043b\u043b\u0438<\/font><\/h4>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/594\/995\/aef\/594995aef57c42a597c5c2770afcf282.png\" \/><\/div>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/792\/3a5\/cb7\/7923a5cb7e36429cacaad61739956285.png\"\/>  <\/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-272231","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272231","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=272231"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/272231\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}