<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Электронный научно-практический журнал «Современные научные исследования и инновации» &#187; Monte Carlo methods</title>
	<atom:link href="http://web.snauka.ru/issues/tag/monte-carlo-methods/feed" rel="self" type="application/rss+xml" />
	<link>https://web.snauka.ru</link>
	<description></description>
	<lastBuildDate>Sat, 18 Apr 2026 09:41:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>π-Test and Monte Carlo Optimization of Pseudo-Random Sequence Generators</title>
		<link>https://web.snauka.ru/en/issues/2018/08/87545</link>
		<comments>https://web.snauka.ru/en/issues/2018/08/87545#comments</comments>
		<pubDate>Thu, 30 Aug 2018 15:07:31 +0000</pubDate>
		<dc:creator>Сучилин Владимир Александрович</dc:creator>
				<category><![CDATA[01.00.00 Physics and mathematics]]></category>
		<category><![CDATA[linear congruence method]]></category>
		<category><![CDATA[Monte Carlo methods]]></category>
		<category><![CDATA[optimization of the pseudo-random sequence generator]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[uniform distribution law]]></category>
		<category><![CDATA[линейный конгруэнтный метод]]></category>
		<category><![CDATA[методы Монте-Карло]]></category>
		<category><![CDATA[оптимизация генератора псевдослучайных последовательностей]]></category>
		<category><![CDATA[равномерный закон распределения]]></category>

		<guid isPermaLink="false">https://web.snauka.ru/issues/2018/08/87545</guid>
		<description><![CDATA[Introduction Pseudo-random sequence generators (PRSG) today are an integral part of fast any application software [1]. Among them, an important role is played by PRSGs with the uniform distribution law from which PRSGs with any other distribution law can be obtained through a transform. In this regard, it is important to be ensured what is [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span>Introduction</span></strong></p>
<p><span>Pseudo-random sequence generators (PRSG) today are an integral part of fast any application software [1]. Among them, an important role is played by PRSGs with the uniform distribution law from which PRSGs with any other distribution law can be obtained through a transform. In this regard, it is important to be ensured what is about a good quality of the uniform distribution to be used. To do this, there are various methods for PRSG testing [2].</span></p>
<p><span>In this paper, we offer the simple to implement test, as well as a method based on Monte Carlo methods for optimizing PRSGs with the uniform distribution law [3].</span></p>
<p><strong><span>Using Monte Carlo methods</span></strong></p>
<p><span>In Monte Carlo methods, a PRSG is usually first selected, and on its basis the required estimation of the object under study is formed. We will proceed, on the contrary, from the reference value of the required evaluation, in order to estimate on its basis the real quality of PRSG. To do this, we consider a definite integral:</span></p>
<p><span>S = </span><img src="http://content.snauka.ru/web/87545_files/0.gif" alt="" width="104" height="29" /><span>(1)</span></p>
<p><span>Note that since this integral is a well-known one (namely, S = </span><span>π</span><span>/2 [4]), it can be just used as the required reference value.</span></p>
<p><span>Calculation of the integral (1) by Monte Carlo methods has to do with the well-known mathematical model [3]. In this model, points within a unit square in which the unit circle is inscribed are randomly sampled, and then the ratio of the number of points M being sampled in the unit circle to the total number of selected points N is determined. In this case, it can be obtained:</span></p>
<p><strong><span>π</span></strong><span> ≈ 4·M / N (2)</span></p>
<p><span>In the case of an ideal PRSG, the calculation accuracy through this model increases in proportion to the number of sampled points. However, real PRSGs (for example, due to the pseudo-random sequence generation method being used) often do not provide the desired quality of uniform distribution [5].</span></p>
<p><span>In this case, the quality of a PRSG estimated by means of how accurately the number </span><span>π</span><span> is determined. This procedure, which we call then “</span><span>π</span><span>-Test”, can be used to evaluate the quality of any PRSG with the uniform distribution law. Below we provide two modules the first of which implements the </span><span>π</span><span>-Test (specifically using the function Math.GetRandomNumber [6]), and the second provides a pseudo-random sequence based on the linear congruential method (LCM) [2].</span></p>
<p><strong><span>Notes</span></strong><span>:</span></p>
<p><span>1. The program modules presented below are intellectual property, and their use requires a reference to this article.</span></p>
<p><span>2. The values of Par1, Par2, Par3 by the second module are part of the author&#8217;s know-how and can be provided upon request.</span></p>
<p><strong><span>Table 1 </span></strong><span>- Module </span><strong><span style="text-decoration: underline;"><span>π</span></span></strong><span style="text-decoration: underline;"><span>-Test</span></span></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top">
<td width="380"><em><span style="color: #008000;">&#8216;GetRandomNumber Pi-Test by Method Monte-Carlo</span></em><span>N</span><span style="color: #800000;">=</span><span style="color: #006062;">Math</span><span style="color: #800000;">.</span><span style="color: #a11f12;">Power</span><span style="color: #800000;">(</span><span style="color: #ff8141;">10</span><span style="color: #800000;">,</span><span style="color: #ff8141;">5</span><span style="color: #800000;">)</span></p>
<p><span>z</span><span style="color: #800000;">=</span><span style="color: #006062;">Math</span><span style="color: #800000;">.</span><span style="color: #a11f12;">Power</span><span style="color: #800000;">(</span><span style="color: #ff8141;">10</span><span style="color: #800000;">,</span><span style="color: #ff8141;">7</span><span style="color: #800000;">)</span></p>
<p><span>CycleNumber</span><span style="color: #800000;"> =</span><span style="color: #ff8141;">0</span></p>
<p><span>Wid</span><span style="color: #800000;">:</span></p>
<p><span>CycleNumber</span><span style="color: #800000;">=</span><span> CycleNumber</span><span style="color: #800000;">+</span><span style="color: #ff8141;">1</span></p>
<p><span>M</span><span style="color: #800000;">=</span><span style="color: #ff8141;">0</span></p>
<p><strong><span style="color: #8080ff;">For</span></strong><span> i </span><span style="color: #800000;">= </span><span style="color: #ff8141;">1</span><span> </span><strong><span style="color: #8080ff;">to</span></strong><span> N</span></p>
<p><span>x</span><span style="color: #800000;">=</span><span style="color: #006062;">Math</span><span style="color: #800000;">.</span><span style="color: #a11f12;">GetRandomNumber</span><span style="color: #800000;">(</span><span>z</span><span style="color: #800000;">)/</span><span>z</span><span style="color: #800000;">-</span><span style="color: #ff8141;">0.5</span></p>
<p><span>y</span><span style="color: #800000;">=</span><span style="color: #006062;">Math</span><span style="color: #800000;">.</span><span style="color: #a11f12;">GetRandomNumber</span><span style="color: #800000;">(</span><span>z</span><span style="color: #800000;">)/</span><span>z</span><span style="color: #800000;">-</span><span style="color: #ff8141;">0.5</span></p>
<p><strong><span style="color: #8080ff;">If</span></strong><span> </span><span style="color: #800000;">(</span><span>x</span><span style="color: #800000;">*</span><span>x</span><span style="color: #800000;">+</span><span>y</span><span style="color: #800000;">*</span><span>y</span><span style="color: #800000;">)</span><span> </span><span style="color: #800000;">&lt;=</span><span> </span><span style="color: #ff8141;">0.25</span><span> </span><strong><span style="color: #8080ff;">Then</span></strong></p>
<p><span>M</span><span style="color: #800000;">=</span><span>M</span><span style="color: #800000;">+</span><span style="color: #ff8141;">1</span></p>
<p><strong><span style="color: #8080ff;">EndIf</span></strong></p>
<p><strong><span style="color: #8080ff;">Endfor</span></strong></p>
<p><span>PiValue</span><span style="color: #800000;">=</span><span style="color: #ff8141;">4</span><span style="color: #800000;">*</span><span>M</span><span style="color: #800000;">/</span><span>N</span></p>
<p><em><span style="color: #008000;">&#8216;Determination of mean of the sample</span></em></p>
<p><span>MeanPiValue</span><span style="color: #800000;">=(</span><span>MeanPiValue</span><span style="color: #800000;">*(</span><span>CycleNumber</span><span style="color: #800000;">-</span><span style="color: #ff8141;">1</span><span style="color: #800000;">)+</span><span>PiValue</span><span style="color: #800000;">)/</span><span>CycleNumber</span></p>
<p><span style="color: #006062;">textwindow</span><span style="color: #800000;">.</span><span style="color: #a11f12;">Write</span><span style="color: #800000;">(</span><span style="color: #a16252;">&#8221; &#8220;</span><span style="color: #800000;">+</span><span>MeanPiValue</span><span style="color: #800000;">)</span></p>
<p><strong><span style="color: #8080ff;">If</span></strong><span> CycleNumber </span><span style="color: #800000;">&lt;</span><span> </span><span style="color: #ff8141;">25</span><span> </span><strong><span style="color: #8080ff;">Then</span></strong></p>
<p><strong><span style="color: #8080ff;">Goto</span></strong><span> Wid</span></p>
<p><strong><span style="color: #8080ff;">EndIf</span></strong></p>
<p><em><span style="color: #008000;">&#8216;End of program</span></em></td>
</tr>
</tbody>
</table>
<p><strong>Table 2 </strong>- Module <span style="text-decoration: underline;">LCM</span></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top">
<td width="380"><em><span style="color: #008000;">&#8216;Modificated LCG {0,1}</span></em><strong><span style="color: #8080ff;">Sub</span></strong><span> LCG</span></p>
<p><span>g1</span><span style="color: #800000;">=</span><span style="color: #006062;">Par1</span><span style="color: #800000;">*</span><span>RandValue</span></p>
<p><span>g2</span><span style="color: #800000;">=</span><span style="color: #006062;">Math</span><span style="color: #800000;">.</span><span style="color: #a11f12;">Floor</span><span style="color: #800000;">(</span><span>g1</span><span style="color: #800000;">)</span></p>
<p><span>g3</span><span style="color: #800000;">=</span><span>g1</span><span style="color: #800000;">-</span><span>g2</span></p>
<p><span>ga</span><span style="color: #800000;">=</span><span>g3</span><span style="color: #800000;">*</span><span style="color: #006062;">Par2</span></p>
<p><span>gb</span><span style="color: #800000;">=</span><span>g3</span><span style="color: #800000;">*</span><span style="color: #006062;">Par3</span></p>
<p><span>RandValue</span><span style="color: #800000;">=</span><span>gb</span><span style="color: #800000;">-</span><span>ga</span></p>
<p><span>ODV</span><span style="color: #800000;">:</span></p>
<p><em><span style="color: #008000;">&#8216;Normalisation</span></em></p>
<p><strong><span style="color: #8080ff;">If</span></strong><span> RandValue</span><span style="color: #800000;"> &gt; </span><span style="color: #ff8141;">1</span><span> </span><strong><span style="color: #8080ff;">Then</span></strong></p>
<p><span>RandValue</span><span style="color: #800000;">=</span><span>RandValue</span><span style="color: #800000;">/</span><span style="color: #ff8141;">10</span></p>
<p><strong><span style="color: #8080ff;">Goto</span></strong><span> ODV</span></p>
<p><strong><span style="color: #8080ff;">EndIf</span></strong></p>
<p><strong><span style="color: #8080ff;">EndSub</span></strong></td>
</tr>
</tbody>
</table>
<p><span>The results of the </span><span>π</span><span>-Test with Math.GetRandomNumber are shown in the diagram below. For comparison, here are also the results based on the LCM. The reference points on the diagram correspond to the average estimation for </span><span>π</span><span> as the number of cycle’s increases.</span></p>
<p>&nbsp;</p>
<div align="center"><img src="https://web.snauka.ru/wp-content/uploads/2018/09/092518_1555_1.png" alt="" /></div>
<div align="center"><span>Fig. 1 Results of the </span><strong><span>π</span></strong><strong><span>-</span></strong><span>Test</span></div>
<p><em><span>Series1 &#8211; Based on Math.GetRandomNumber</span></em><br />
<em><span>Series2 &#8211; Based on the LCM</span></em><br />
<em><span>Series3 &#8211; Level of π</span></em></p>
<p><span>This diagram clearly shows that the quality of the standard PRSG generator leaves much to be desired. Here, indeed, compared to the LCM, the standard PRSG has two disadvantages.</span></p>
<p><span>First, it has a relatively large variance, which is indicated by the phase of &#8220;acceleration&#8221; (the first 10 points of the diagram).</span></p>
<p><span>Secondly, at the stationary section (points 11 to 23), the accuracy of approximation </span><span>π</span><span> does not exceed the 2nd decimal place, while in the case of the LCM it is provided by 4 decimal place.</span></p>
<p><span>This can be explained by the fact that in this model the generated points are distributed unevenly in the unit square. At the same time, their density in the unit circle occurs to be higher.</span></p>
<p><span>In addition, the results of the </span><span>π</span><span>-Test illustrate the fact that the quality of different PRSG can vary significantly [5].</span></p>
<p><strong><span>Optimization of PRSG</span></strong></p>
<p><span>To optimize a PRSG with the uniform distribution law, one can use the quadratic criterion [7]:</span></p>
<p><strong><span>E</span></strong><span> =&gt; min (ӯ &#8211; a)</span><sup><span>2</span></sup><span> (3)</span><br />
<strong><span>Ф</span></strong><span>(</span><span>μ</span><span>,y))</span></p>
<p><span>where</span><br />
<span>ӯ –sample mean </span><br />
<span>а –reference value</span></p>
<p><span>Note, the function </span><strong><span>Ф</span></strong><span>(</span><span>μ</span><span>,y) has a similarity to the functions that are used to the pseudo-random sequence, for example, to a normal distribution (Box-Muller transform [2]). However, in this mathematical model, this function serves only to correct the distribution law in order to improve the quality of PRSG.</span></p>
<p><span>We consider the above formulation of the problem as applied to a correcting function of the form:</span></p>
<p><span>Ф(</span><span>μ</span><span>,y) =(y +</span><span>μ</span><span>·sin(y</span><span>π</span><span>)) (4)</span></p>
<p><span>where y is a random variable in the {0,1} interval formed by the standard PRSG generator and </span><span>μ</span><span> is a small parameter (| </span><span>μ</span><span> | &lt;&lt; 1), since, as a rule, only an insignificant correction of the distribution law of the PRSG is required for optimization. Note, with this definition, in addition, the following necessary relations are satisfied:</span></p>
<p><span>0 &gt; Ф(</span><span>μ</span><span>, y) &lt; 1 (5)</span><br />
<span>Ф(0, y) = y</span></p>
<p><span>Below are the configurations of the function (5) for the three main cases of the parameter </span><span>μ</span><span>.</span></p>
<p>&nbsp;</p>
<div align="center"><img src="https://web.snauka.ru/wp-content/uploads/2018/09/092518_1555_2.png" alt="" /></div>
<div align="center"><span>Fig. 2 Configurations of the function by different </span><span>μ</span></div>
<p><em><span>Series1 </span></em><span>- </span><span>μ</span><span> &lt; 0</span><br />
<em><span>Series2 </span></em><span>- </span><span>μ</span><span> &gt; 0</span><br />
<em><span>Series3</span></em><span> - </span><span>μ</span><span> = 0</span></p>
<p><strong><span>Discussion</span></strong></p>
<p><span>In computer simulation, as a result of optimization of the standard PRSG, the value of </span><span>μ</span><span> is obtained by the above-described scheme, which provides a better approximation of </span><span>π</span><span> and thus a higher quality of the implementation with the standard function Math.GetRandomNumber after its correction. We note that in this case the parameter </span><span>μ</span><span> turned out to be greater than zero, i.e. the configuration of the function (4) corresponds to the red curve in Fig. 2. The average estimations obtained in the Monte Carlo model with optimized PRSG are presented in the diagram below, together with the estimation for the standard PRSG from the diagram in Fig. 2.</span></p>
<p>&nbsp;</p>
<div align="center"><img src="https://web.snauka.ru/wp-content/uploads/2018/09/092518_1555_3.png" alt="" /></div>
<div align="center"><span>Fig. 3 Results of optimization</span></div>
<p><em><span>Series1 &#8211; Before optimization</span></em><br />
<em><span>Series2 &#8211; After optimization</span></em><br />
<em><span>Series3 &#8211; Level of </span></em><em><span>π</span></em></p>
<p><span>From this diagram, it can be seen that the Monte Carlo model with an optimized PRSG generator has a smaller dispersion and improves the approximation of the </span><span>π</span><span> (according to the results &#8211; up to the third decimal place).</span></p>
<p><strong><span>Conclusion</span></strong></p>
<p><span>Above, we considered the formulation of a problem in which the Monte Carlo methods are used to evaluate the quality PRSG with the uniform distribution law. In the framework of this problem formulation, a </span><span>π</span><span>-Test with a simple implementation considered above is proposed that can be used to verify the quality of any PRSG with the uniform distribution law. Therefore, this test should be a good supplement to existing testing methods. In addition, it has been shown that this </span><span>π</span><span>-Test can be successfully used to optimize PRSG with the uniform distribution law. Performance of the proposed approach is confirmed by the results of computer simulation.</span></p>
]]></content:encoded>
			<wfw:commentRss>https://web.snauka.ru/en/issues/2018/08/87545/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inverse Box-Muller Transform and Its Application</title>
		<link>https://web.snauka.ru/en/issues/2018/10/87617</link>
		<comments>https://web.snauka.ru/en/issues/2018/10/87617#comments</comments>
		<pubDate>Thu, 04 Oct 2018 16:54:17 +0000</pubDate>
		<dc:creator>Сучилин Владимир Александрович</dc:creator>
				<category><![CDATA[05.00.00 Technical sciences]]></category>
		<category><![CDATA[Box-Muller transform]]></category>
		<category><![CDATA[Monte Carlo methods]]></category>
		<category><![CDATA[random sequence]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[методы Монте-Карло]]></category>
		<category><![CDATA[преобразование Бокса-Мюллера]]></category>
		<category><![CDATA[случайная последовательность]]></category>

		<guid isPermaLink="false">https://web.snauka.ru/issues/2018/10/87617</guid>
		<description><![CDATA[Introduction To date, a pseudo-random number generator (PRNG) is considered indispensable for any modern software package [1]. However, the standard software functions in use generating pseudo-random numbers (PRN) differs among themselves in regard to the quality that may exercise unpredictable effects on the results of statistical calculations [2]. From this point of view, the quality [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span>Introduction</span></strong></p>
<p><span>To date, a pseudo-random number generator (</span><em><span>PRNG</span></em><span>) is considered indispensable for any modern software package [1]. However, the standard software functions in use generating pseudo-random numbers (</span><em><span>PRN</span></em><span>) differs among themselves in regard to the quality that may exercise unpredictable effects on the results of statistical calculations [2]. From this point of view, the quality of a </span><em><span>PRNG</span></em><span> plays an important role [3]. In this article, for the purpose of evaluation of </span><em><span>PRNG</span></em><span> quality, a new two-stage </span><em><span>PRNG</span></em><span> test procedure is presented, the core of which is the </span><em><span>Inverse</span></em><span> </span><em><span>Box-Muller Transform</span></em><span> </span><em><span>(BMT</span></em><span>) [4]. Below the </span><em><span>Direct</span></em><span> </span><em><span>BMT </span></em><span>is</span><em><span> </span></em><span>described and on the basis of this description the </span><em><span>Inverse</span></em><span> </span><em><span>BMT</span></em><span> is formulated.</span></p>
<p><strong><span>Direct Box-Muller Transform</span></strong></p>
<p><span>For the transition from the </span><em><span>Gaussian type PRN</span></em><span> to the </span><em><span>PRN</span></em><span> with the uniform distribution mainly use the well-known </span><em><span>Direct</span></em><span> </span><em><span>BMT</span></em><span>, that can be presented as follows [4]:</span></p>
<p><span>u = </span><img src="http://content.snauka.ru/web/87617_files/0.gif" alt="" width="136" height="26" /><span> (1)</span><br />
<span>v = </span><img src="http://content.snauka.ru/web/87617_files/0(1).gif" alt="" width="134" height="26" /></p>
<p><span>where</span><br />
<span>x и y &#8211; two statistically independent random variable distributed uniformly on </span><br />
<span>interval (0,1)</span><br />
<span>u и v &#8211; two statistically independent random variable distributed normally with</span></p>
<p><span>average and variance equal to 0 and 1 accordingly</span><span>The standard use of the </span><em><span>Direct</span></em><span> </span><em><span>BMT</span></em><span> in the form (1) allows obtaining </span><em><span>PRNG</span></em><span> with a normal distribution on the basis of an eventually ideal </span><em><span>PRNG</span></em><span> with the uniform distribution.</span></p>
<p><span>As a matter of fact, the </span><em><span>PRNGs</span></em><span> used in software do not provide the perfect uniform distribution. That is due to the methods of </span><em><span>PRN</span></em><span> generating and limitations of the decimal places of the variable used by calculations in the course of statistical calculations.</span></p>
<p><strong><span>Inverse Box-Muller Transform</span></strong></p>
<p><span>Opposing to the formulation given above, an approach may be considered where conversion of the </span><em><span>PRN</span></em><span> with the normal distribution leads to the adequate </span><em><span>PRN</span></em><span> with the uniform distribution. As will be shown below, due to such inverse transform, a quality check of the </span><em><span>Gaussian type PRNG</span></em><span> can be reduced to the evaluation of the quality of the </span><em><span>PRNG</span></em><span> with the uniform distribution.</span></p>
<p><span>The </span><em><span>Inverse BMT</span></em><span> can be derived immediately from the expression (1). To do this, at first one should divide the second entity in (1) by the first one, as a result of which we obtain:</span></p>
<p><span>v/u = </span><img src="http://content.snauka.ru/web/87617_files/0(2).gif" alt="" width="66" height="22" /><span> (2)</span></p>
<p><span>On the other hand, after squaring and subsequent addition of the both entity in (1), follows:</span></p>
<p><span>u</span><sup><span>2</span></sup><span>+v</span><sup><span>2</span></sup><span> = - </span><span>2</span><span> </span><strong><span>ln</span></strong><span> y (3)</span></p>
<p><span>Finally, on the basis of equalities (2) and (3), the </span><em><span>Inverse BMT</span></em><span> can be formulated as follows:</span></p>
<p><span>x =</span><img src="http://content.snauka.ru/web/87617_files/0(3).gif" alt="" width="62" height="22" /><span> / 2</span><em><span>р</span></em><span> (4)</span><br />
<span>y = </span><strong><span>e</span></strong><strong><sup><span>-</span></sup></strong><sup><span>s</span></sup><br />
<span>where </span><br />
<span>p = v/u </span><br />
<span>s = (u</span><sup><span>2</span></sup><span>+v</span><sup><span>2</span></sup><span>)/2</span><br />
<span>u и v &#8211; two statistically independent random variable distributed normally with </span>average and variance equal to 0 and 1 accordinglyx и y &#8211; two statistically independent random variable distributed uniformly oninterval (0,1)<em>Inverse</em> <em>BMT</em> is unique, and its superposition with <em>Direct</em> <em>BMT</em> leads to an identity. The formal proving of this statement is beyond the scope of this article, but its validity was confirmed through computer simulation with the modules shown in the following tables. Below, there is also the original function <em>GetNormRandNumber</em> (not given here) that allows obtaining the <em>Gaussian</em> type <em>PRN</em>.</p>
<p style="text-align: justify;"><span style=" Arial;  medium;">Table 1. Program “Superposition of Direct &amp; Inverse BMT”</span></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top">
<td width="484"><em><span style="color: #008000;  Consolas;">&#8216;Main programm</span></em><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8221; Box-Muller Transform Example &#8220;</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Read</span><span style="color: #800000;  Consolas;">()</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Read</span><span style="color: #800000;  Consolas;">()</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8221; Initial Random number &#8220;</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8220;Direct Transform &#8220;</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8220;Inverse Transform &#8220;</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Read</span><span style="color: #800000;  Consolas;">()</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221;</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Read</span><span style="color: #800000;  Consolas;">()</span></p>
<p><strong><span style="color: #8080ff;  Consolas;">For</span></strong><span style=" Consolas;"> i</span><span style="color: #800000;  Consolas;">=</span><span style="color: #ff8141;  Consolas;">1</span><strong><span style="color: #8080ff;  Consolas;">To</span></strong><span style=" Consolas;"> N_Sample</span></p>
<p><em><span style="color: #008000;  Consolas;"> &#8216;Direct Transform</span></em></p>
<p><span style=" Consolas;"> DirBoxMuller</span><span style="color: #800000;  Consolas;">()</span></p>
<p><em><span style="color: #008000;  Consolas;"> &#8216;Invers Transform</span></em></p>
<p><span style=" Consolas;"> InvBoxMuller</span><span style="color: #800000;  Consolas;">()</span></p>
<p><span style="color: #006062;  Consolas;"> textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8220;&#8221;</span><span style="color: #800000;  Consolas;">+</span><span style=" Consolas;">x1</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8221; &#8220;</span><span style="color: #800000;  Consolas;">+</span><span style=" Consolas;">u</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8221; &#8220;</span><span style="color: #800000;  Consolas;">+</span><span style=" Consolas;">x2</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;"> textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Read</span><span style="color: #800000;  Consolas;">()</span></p>
<p><span style="color: #006062;  Consolas;"> textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8220;&#8221;</span><span style="color: #800000;  Consolas;">+</span><span style=" Consolas;">y1</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8221; &#8220;</span><span style="color: #800000;  Consolas;">+</span><span style=" Consolas;">v</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;">textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Write</span><span style="color: #800000;  Consolas;">(</span><span style="color: #a16252;  Consolas;">&#8221; &#8220;</span><span style="color: #800000;  Consolas;">+</span><span style=" Consolas;">y2</span><span style="color: #800000;  Consolas;">)</span></p>
<p><span style="color: #006062;  Consolas;"> textwindow</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Read</span><span style="color: #800000;  Consolas;">()</span></p>
<p><strong><span style="color: #8080ff;  Consolas;">EndFor</span></strong></p>
<p><em><span style="color: #008000;  Consolas;">&#8216;End of programm</span></em></td>
</tr>
</tbody>
</table>
<p><span style=" Arial;  medium;">Table 2. Module “Direct BMT” </span></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top">
<td width="484"><strong><span style="color: #8080ff;  Consolas;">Sub</span></strong><span style=" Consolas;"> DirBoxMuller</span><span style=" Consolas;"> x1</span><span style="color: #800000;  Consolas;">=</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">GetRandomNumber</span><span style="color: #800000;  Consolas;">(</span><span style=" Consolas;">z</span><span style="color: #800000;  Consolas;">)/</span><span style=" Consolas;">z</span></p>
<p><span style=" Consolas;"> y1</span><span style="color: #800000;  Consolas;">=</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">GetRandomNumber</span><span style="color: #800000;  Consolas;">(</span><span style=" Consolas;">z</span><span style="color: #800000;  Consolas;">)/</span><span style=" Consolas;">z</span></p>
<p><span style=" Consolas;"> u</span><span style="color: #800000;  Consolas;">=</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Cos</span><span style="color: #800000;  Consolas;">(</span><span style="color: #ff8141;  Consolas;">2</span><span style="color: #800000;  Consolas;">*</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">pi</span><span style="color: #800000;  Consolas;">*</span><span style=" Consolas;">x</span><span style="color: #800000;  Consolas;">)*</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">SquareRoot</span><span style="color: #800000;  Consolas;">(-</span><span style="color: #ff8141;  Consolas;">2</span><span style="color: #800000;  Consolas;">*</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">NaturalLog</span><span style="color: #800000;  Consolas;">(</span><span style=" Consolas;">y</span><span style="color: #800000;  Consolas;">))</span></p>
<p><span style=" Consolas;"> v</span><span style="color: #800000;  Consolas;">=</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Sin</span><span style="color: #800000;  Consolas;">(</span><span style="color: #ff8141;  Consolas;">2</span><span style="color: #800000;  Consolas;">*</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">pi</span><span style="color: #800000;  Consolas;">*</span><span style=" Consolas;">x</span><span style="color: #800000;  Consolas;">)*</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">SquareRoot</span><span style="color: #800000;  Consolas;">(-</span><span style="color: #ff8141;  Consolas;">2</span><span style="color: #800000;  Consolas;">*</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">NaturalLog</span><span style="color: #800000;  Consolas;">(</span><span style=" Consolas;">y</span><span style="color: #800000;  Consolas;">))</span></p>
<p><strong><span style="color: #8080ff;  Consolas;">EndSub</span></strong></td>
</tr>
</tbody>
</table>
<p><span style=" Arial;  medium;">Table 3. Module “Inverse BMT”</span></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top">
<td width="276"><strong><span style="color: #8080ff;  Consolas;">Sub</span></strong><span style=" Consolas;"> InvBoxMuller</span><span style=" Consolas;"> GetNormRandNumber</span><span style="color: #800000;  Consolas;">()</span></p>
<p><span style=" Consolas;"> u</span><span style="color: #800000;  Consolas;">=</span><span style=" Consolas;">NormValue</span></p>
<p><span style=" Consolas;"> GetNormRandNumber</span><span style="color: #800000;  Consolas;">()</span></p>
<p><span style=" Consolas;"> v</span><span style="color: #800000;  Consolas;">=</span><span style=" Consolas;">NormValue</span></p>
<p><span style=" Consolas;"> x2</span><span style="color: #800000;  Consolas;">=</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">ArcTan</span><span style="color: #800000;  Consolas;">(</span><span style=" Consolas;">v</span><span style="color: #800000;  Consolas;">/</span><span style=" Consolas;">u</span><span style="color: #800000;  Consolas;">)/(</span><span style="color: #ff8141;  Consolas;">2</span><span style="color: #800000;  Consolas;">*</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">pi</span><span style="color: #800000;  Consolas;">)</span></p>
<p><em></em><span style=" Consolas;"> y2</span><span style="color: #800000;  Consolas;">=</span><span style="color: #006062;  Consolas;">Math</span><span style="color: #800000;  Consolas;">.</span><span style="color: #a11f12;  Consolas;">Power</span><span style="color: #800000;  Consolas;">(</span><span style=" Consolas;">exp</span><span style="color: #800000;  Consolas;">,-(</span><span style=" Consolas;">u</span><span style="color: #800000;  Consolas;">*</span><span style=" Consolas;">u </span><span style="color: #800000;  Consolas;">+</span><span style=" Consolas;">v</span><span style="color: #800000;  Consolas;">*</span><span style=" Consolas;">v</span><span style="color: #800000;  Consolas;">/</span><span style="color: #ff8141;  Consolas;">2</span><span style="color: #800000;  Consolas;">)</span></p>
<p><strong><span style="color: #8080ff;  Consolas;">EndSub</span></strong></td>
</tr>
</tbody>
</table>
<p><span style=" Arial;  medium;">Table 4. The screenshot “Superposition of Direct &amp; Inverse Box-Muller”.</span></p>
<p style="text-align: left;"><img src="https://web.snauka.ru/wp-content/uploads/2018/10/100418_1649_11.png" alt="" /></p>
<p style="text-align: justify;"><span>In the screenshot above, it is easy to see that the consistent use of the <em>Direct</em> and <em>Inverse BMTs</em> leads to the initial <em>PRN</em>. Thus, it shows that the superposition of the both transforms is unique and leads to identity.<br />
</span></p>
<p style="text-align: justify;"><span><strong>Application of the Inverse Box-Muller Transform<br />
</strong></span></p>
<p style="text-align: justify;"><span>In regard to the representation above, the procedure for the quality evaluation of <em>PRNG</em> can be implemented in the form of a two-stage procedure in which the <em>PRN</em> with the uniform distribution will be formed by means of <em>Inverse BMT</em>, and then the <em><strong>π</strong>-Test</em> is applied [5].<br />
</span></p>
<p style="text-align: justify;"><span>Generally, to check the effectiveness of the described approach the <em>Central Limit Theorem Probability</em> can be used [6]. According to this theorem, a <em>PRN</em> which elements defined as the average of the original set of statistically independent random variable has the <em>Gaussian</em> distribution. The program generating the <em>Gaussian type PRN</em> on the basis of the N-set mentioned above is presented below.<br />
</span></p>
<p style="text-align: justify;"><span style=" Arial;  medium;">Table 5. Module “Gaussian type PRNG”</span></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr valign="top">
<td width="276"><strong><span style="color: #8080ff;  Consolas;">Sub</span></strong><span style=" Consolas;"> GetNormRandNumber</span><span style=" Consolas;"> Smp</span><span style="color: #800000;  Consolas;">=</span><span style="color: #ff8141;  Consolas;">0</span></p>
<p><strong><span style="color: #8080ff;  Consolas;">For</span></strong><span style=" Consolas;"> si</span><span style="color: #800000;  Consolas;">=</span><span style="color: #ff8141;  Consolas;">1</span><strong><span style="color: #8080ff;  Consolas;">To</span></strong><span style=" Consolas;"> N</span></p>
<p><strong><span style="color: #00bfff;  Consolas;">RndLCM()</span></strong></p>
<p><span style=" Consolas;"> Smp</span><span style="color: #800000;  Consolas;">=</span><span style=" Consolas;">Smp</span><span style="color: #800000;  Consolas;">+RandValue</span></p>
<p><strong><span style="color: #8080ff;  Consolas;">EndFor</span></strong></p>
<p><span style=" Consolas;"> NormValue</span><span style="color: #800000;  Consolas;">=</span><span style=" Consolas;">Smp</span><span style="color: #800000;  Consolas;">/</span><span style=" Consolas;">N</span></p>
<p><strong><span style="color: #8080ff;  Consolas;"> EndSub</span></strong></td>
</tr>
</tbody>
</table>
<p><span>Note, a special function <em>RndLCM</em> is applied above, namely one on the basis of <em>Linear Congruential Method (LCM)</em>, which provides a smart <em>PRN</em> with statistically independent variable [5]. The distribution density curves calculated in such way for some values N are represented below.<br />
</span></p>
<p style="text-align: center;"><img src="https://web.snauka.ru/wp-content/uploads/2018/10/100418_1649_12.png" alt="" /><span><br />
</span></p>
<p style="text-align: center;"><span>Fig. 1 Distribution density diagrams for sampled values N on the basis of the <em>Central Limit Theorem Probability</em>.<br />
</span></p>
<p style="text-align: justify;"><span>The diagram below shows results of computer simulation of the proposed two-stage test procedure to the quality evaluation of the <em>Gaussian type PRNG</em> by N = 6 vs. results for two other (reference) <em>PRNGs</em> with uniform distribution.<br />
</span></p>
<p style="text-align: center;"><img src="https://web.snauka.ru/wp-content/uploads/2018/10/100418_1649_13.png" alt="" /><span><br />
</span></p>
<p style="text-align: center;"><span>Fig. 2 <em>PRNGs</em> quality diagram.<br />
</span></p>
<p style="text-align: justify;"><span>The curves in the Fig. 2 represent the dynamics of the 23 sequential test sessions.<br />
</span></p>
<p style="text-align: justify;"><span>The legend of the Fig. 2 is as follows:<br />
</span></p>
<p style="text-align: justify;"><span>GRN &#8211; immediate <em>π-Test</em> of the <em>PRNG</em> with the use of function <em>GetRandomNumber</em><br />
</span></p>
<p style="text-align: justify;"><span>TRF &#8211;      two-stage procedure with the use of <em>Central Limit Theorem Probability </em>on the<br />
</span></p>
<p style="text-align: justify;"><span>first step and<em> Inverse BMT </em>on the second<em><br />
</em></span></p>
<p style="text-align: justify;"><span>LCM &#8211; immediate <em>π-Test</em> of the <em>PRNG</em> based on the <em>Linear Congruential Method<br />
</em></span></p>
<p style="text-align: justify;"><span>PI &#8211;     the value of <em>π </em>( 3.14159…)<br />
</span></p>
<p style="text-align: justify;"><span><strong>Discussion<br />
</strong></span></p>
<p style="text-align: justify;"><span>The <em>blue</em> curve<em><br />
</em>in the Fig. 2 corresponds to the <em><strong>π</strong>-Test</em> by the standard function <em>GetRandomNumber</em> with uniform distribution [7], while the second diagram (<em>red </em>curve) was calculated by means of the two-stage procedure described above. It should be emphasized that hereby a comparatively &#8220;simple&#8221; generator on the basis of the <em>Central Limit Theorem Probability</em> was applied. At the same time, it is easy to see that the use of <em>GetRandomNumber</em> leads to the worst indices.<em><br />
</em>It is all the more remarkable that in this case the two-stage testing procedure using <em>Inverse BMT</em> has a fairly smart match with the &#8220;LCM&#8221;<em><br />
</em>curve that is meanwhile the best of all and practically provide the approximation of the number <strong><em>π</em></strong> with the same accuracy. However, this of course does not preclude the use of the standard statistical testing methods for quality check of <em>PRNGs</em> and can be a good complement to them.<br />
</span></p>
<p style="text-align: justify;"><span><strong>Conclusion<br />
</strong></span></p>
<p style="text-align: justify;"><span>The <em>Inverse Box-Muller transform</em> was considered, which allows the transition from <em>Gaussian type PRN</em> to the adequate <em>PRN</em> with uniform distribution. A procedure for testing a <em>Gaussian type PRNG</em> is proposed by which after applying of the described <em>Inverse BMT</em> the quality of the <em>PRNG</em> with the uniform distribution (by means of <em><strong>π</strong>-Test</em>) can be evaluated. The results of computer simulations confirm the effectiveness of the proposed approach. In addition, the described testing procedure is suitable for the testing of <em>PRNGs</em> of any type, since it uses just a random sequence with statistically independent variable. But the latter can belong to any <em>PRNG</em> and thus can be reduced to the <em>Gaussian type</em> sequence on the basis of the <em>Central Limit Theorem Probability</em>.</span></p>
]]></content:encoded>
			<wfw:commentRss>https://web.snauka.ru/en/issues/2018/10/87617/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
