<?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; uniform distribution law</title>
	<atom:link href="http://web.snauka.ru/issues/tag/uniform-distribution-law/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>
	</channel>
</rss>
