<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.random.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.lcg-value.php',
    1 => 'lcg_value',
    2 => '複合線形合同法',
  ),
  'up' => 
  array (
    0 => 'ref.random.php',
    1 => 'Random 関数',
  ),
  'prev' => 
  array (
    0 => 'function.getrandmax.php',
    1 => 'getrandmax',
  ),
  'next' => 
  array (
    0 => 'function.mt-getrandmax.php',
    1 => 'mt_getrandmax',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/random/functions/lcg-value.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.lcg-value" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">lcg_value</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">lcg_value</span> &mdash; <span class="dc-title">複合線形合同法</span></p>

 </div>

 <div id="function.lcg-value-refsynopsisdiv">
  <div class="warning"><strong class="warning">警告</strong><p class="simpara">この関数は PHP 8.4.0 で
<em>非推奨</em>になります。この関数に頼らないことを強く推奨します。</p></div>
 </div>

 <div class="refsect1 description" id="refsect1-function.lcg-value-description">
  <h3 class="title">説明</h3>
   <div class="methodsynopsis dc-description">
    <span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
    <span class="methodname"><strong>lcg_value</strong></span>(): <span class="type"><a href="language.types.float.php" class="type float">float</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>lcg_value()</strong></span> は、(0, 1)の範囲の疑似乱数を返します。
   この関数は、周期が 2^31 - 85 および 2^31 - 249 の 2 つの CG を組み合わせます。
   この関数の周期はこれら 2 つの素数の積と等価です。
  </p>
  <div class="caution"><strong class="caution">警告</strong>
 <p class="para">
  この関数が生成する値は、暗号学的にセキュアではありません。そのため、これを暗号や、戻り値を推測できないことが必須の値として使っては <em>いけません</em>。
 </p>
 <p class="para">
  暗号学的にセキュアな乱数が必要な場合は、<span class="classname"><a href="class.random-randomizer.php" class="classname">Random\Randomizer</a></span> を <span class="classname"><a href="class.random-engine-secure.php" class="classname">Random\Engine\Secure</a></span> と一緒に使いましょう。簡単なユースケースの場合、<span class="function"><a href="function.random-int.php" class="function">random_int()</a></span> と <span class="function"><a href="function.random-bytes.php" class="function">random_bytes()</a></span> 関数が、オペレーティングシステムの <abbr title="Cryptographically Secure PseudoRandom Number Generator">CSPRNG</abbr> を使った、 便利で安全な <abbr title="Application Programming Interface">API</abbr> を提供します。
 </p>
</div>
  <div class="caution"><strong class="caution">警告</strong>
   <p class="para">
    乗算や加算(いわゆるアフィン変換)を使って、この関数の戻り値を異なる区間に拡大/縮小すると、結果の値に偏りが出るかもしれません。なぜなら、浮動小数点数は数直線上で均一に分布するわけではないからです。全ての値が浮動小数点数によって正確に表現できるとは限らないので、アフィン変換の結果が求める区間から外れた値になってしまう可能性もあります。
   </p>
   <p class="para">
    任意の区間内で、ランダムな浮動小数点数の値を生成する場合、
    <span class="methodname"><a href="random-randomizer.getfloat.php" class="methodname">Random\Randomizer::getFloat()</a></span> を使いましょう。
    任意の区間内で、ランダムな整数の値を生成する場合、
    <span class="methodname"><a href="random-randomizer.getint.php" class="methodname">Random\Randomizer::getInt()</a></span> を使いましょう。
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.lcg-value-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">この関数にはパラメータはありません。</p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.lcg-value-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   0.0 と 1.0 の範囲の疑似乱数(0.0 と 1.0 を含みます)を、
   浮動小数点数で返します。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.lcg-value-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       この関数は非推奨となりました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.lcg-value-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="random-randomizer.getfloat.php" class="methodname" rel="rdfs-seeAlso">Random\Randomizer::getFloat()</a> - 等確率に選んだ float の値を取得する</span></li>
    <li><span class="methodname"><a href="random-randomizer.getint.php" class="methodname" rel="rdfs-seeAlso">Random\Randomizer::getInt()</a> - 等確率に選ばれる整数を取得する</span></li>
    <li><span class="function"><a href="function.random-int.php" class="function" rel="rdfs-seeAlso">random_int()</a> - 暗号学的にセキュアな方法で、等確率に出る整数を取得する</span></li>
   </ul>
  </p>
 </div>

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