<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.random-engine-mt19937.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'random-engine-mt19937.construct.php',
    1 => 'Random\\Engine\\Mt19937::__construct',
    2 => 'Constructs a new Mt19937 engine',
  ),
  'up' => 
  array (
    0 => 'class.random-engine-mt19937.php',
    1 => 'Random\\Engine\\Mt19937',
  ),
  'prev' => 
  array (
    0 => 'class.random-engine-mt19937.php',
    1 => 'Random\\Engine\\Mt19937',
  ),
  'next' => 
  array (
    0 => 'random-engine-mt19937.debuginfo.php',
    1 => 'Random\\Engine\\Mt19937::__debugInfo',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/random/random/engine/mt19937/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="random-engine-mt19937.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Random\Engine\Mt19937::__construct</h1>
  <p class="verinfo">(PHP 8 &gt;= 8.2.0)</p><p class="refpurpose"><span class="refname">Random\Engine\Mt19937::__construct</span> &mdash; <span class="dc-title">Constructs a new Mt19937 engine</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-random-engine-mt19937.construct-description">
  <h3 class="title">Descrizione</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Random\Engine\Mt19937::__construct</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$seed</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = <strong><code><a href="random.constants.php#constant.mt-rand-mt19937">MT_RAND_MT19937</a></code></strong></span></span>)</div>

  <p class="para rdfs-comment">

  </p>

  <div class="caution"><strong class="caution">Attenzione</strong>
 <p class="para">
  Because the Mt19937 (“Mersenne Twister”) engine accepts only a single 32 bit integer as the
  seed, the number of possible random sequences is limited to just 2<sup class="superscript">32</sup>
  (i.e. 4,294,967,296), despite Mt19937’s huge period of 2<sup class="superscript">19937</sup>-1.
 </p>
 <p class="para">
  When relying on either implicit or explicit random seeding, duplications will appear
  much earlier. Duplicated seeds are expected with 50% probability after less than
  80,000 randomly generated seeds according to the birthday problem. A 10% probability
  of a duplicated seed happens after randomly generating roughly 30,000 seeds.
 </p>
 <p class="para">
  This makes Mt19937 unsuitable for applications where duplicated sequences must not happen with
  more than a negligible probability. If reproducible seeding is required, both the
  <span class="classname"><a href="class.random-engine-xoshiro256starstar.php" class="classname">Random\Engine\Xoshiro256StarStar</a></span> and <span class="classname"><a href="class.random-engine-pcgoneseq128xslrr64.php" class="classname">Random\Engine\PcgOneseq128XslRr64</a></span>
  engines support much larger seeds that are unlikely to collide randomly. If reproducibility
  is not required, the <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span> engine provides cryptographically
  secure randomness.
 </p>
</div>
 </div>


 <div class="refsect1 parameters" id="refsect1-random-engine-mt19937.construct-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <dl>
   
    <dt><code class="parameter">seed</code></dt>
    <dd>
     <p class="para">
      Fills the state with values generated with a linear congruential generator
      that was seeded with <code class="parameter">seed</code> interpreted as an unsigned
      32 bit integer.
     </p>

     <p class="para">
      If <code class="parameter">seed</code> is omitted or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, a random unsigned
      32 bit integer will be used.
     </p>
    </dd>
   
   
    <dt><code class="parameter">mode</code></dt>
    <dd>
     <p class="para">
      Use one of the following constants to specify the implementation of the algorithm to use.
      <ul class="simplelist">
       <li>
        <strong><code><a href="random.constants.php#constant.mt-rand-mt19937">MT_RAND_MT19937</a></code></strong>:
        The correct Mt19937 implementation.
       </li>
       <li>
        <strong><code><a href="random.constants.php#constant.mt-rand-php">MT_RAND_PHP</a></code></strong>:
        An incorrect implementation for backwards compatibility with <span class="function"><a href="function.mt-srand.php" class="function">mt_srand()</a></span> prior to
        PHP 7.1.0.
       </li>
      </ul>
     </p>
     <div class="warning"><strong class="warning">Avviso</strong><p class="simpara">This feature has been
<em>DEPRECATED</em> as of PHP 8.3.0. Relying on this feature
is highly discouraged.</p></div>
    </dd>
   
  </dl>
 </div>


 


 <div class="refsect1 examples" id="refsect1-random-engine-mt19937.construct-examples">
  <h3 class="title">Esempi</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="function"><strong>Random\Engine\Mt19937::__construct()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Uses a random 32 Bit seed.<br /></span><span style="color: #0000BB">$e </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Random\Engine\Mt19937</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">$r </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Random\Randomizer</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>



</div><?php manual_footer($setup); ?>