Author: xiaqqaix@xxxxxxxxx Date: Sun Jan 25 18:51:10 2009 New Revision: 206 Modified: trunk/libs/random/index.html trunk/libs/random/random-concepts.html trunk/libs/random/random-distributions.html trunk/libs/random/random-generators.html trunk/libs/random/random-variate.html Log: random 库更新 Modified: trunk/libs/random/index.html ============================================================================== --- trunk/libs/random/index.html (original) +++ trunk/libs/random/index.html Sun Jan 25 18:51:10 2009 @@ -32,6 +32,7 @@ <h1>Boost 随机数库</h1>+ <p>可以在 <a href="http://www.boost.org/doc/libs/1_37_0/libs/random/index.html";>这里</a> 找到本库的原英文版文档。</p> <p>很多应用都需要随机数。使用 Boost 随机数库 (Boost.Random) 的生成器和分 布可以产生多种具有有用性质的随机数 (例如正态分布)。</p>
<p>请先阅读 <a href="random-concepts.html">概念文档</a>,熟悉一下基本概 念。如果你想要尽快开始,不妨看看 <a href="random_demo.cpp">random_demo.cpp</a>。</p>
Modified: trunk/libs/random/random-concepts.html ============================================================================== --- trunk/libs/random/random-concepts.html (original) +++ trunk/libs/random/random-concepts.html Sun Jan 25 18:51:10 2009 @@ -248,7 +248,7 @@ <table border="1"> <tr>- <th colspan="4" align="center">Random distribution 需求 (以下,加上 number generator, <code>CopyConstructible</code> 和 <code>Assignable</code>)</th> + <th colspan="4" align="center">Random distribution 需求 (以下,加上 Number Generator, <code>CopyConstructible</code> 和 <code>Assignable</code>)</th>
</tr> <tr> Modified: trunk/libs/random/random-distributions.html ============================================================================== --- trunk/libs/random/random-distributions.html (original) +++ trunk/libs/random/random-distributions.html Sun Jan 25 18:51:10 2009 @@ -82,14 +82,14 @@ <td>实数区间 [min, max) 上的连续均匀分布</td>- <td>随机投下一木棒,其角度的弧度数是 [0, 2pi) 上的这种分布 (假设角度 的分布是均匀的)</td> + <td>随机投下一木棍,其偏转角的弧度数是 [0, 2pi) 上的这种分布 (假设偏 转角的分布是均匀的)</td>
</tr> <tr> <td><code><a href= "#bernoulli_distribution">bernoulli_distribution</a></code></td> - <td>伯努利试验 (Bernoulli experiment):离散布尔分布,概率可配置</td> + <td>伯努利试验 (Bernoulli experiment):布尔离散分布,概率可配置</td> <td>投掷硬币 (p=0.5)</td> </tr> @@ -98,7 +98,7 @@ <td><code><a href= "#geometric_distribution">geometric_distribution</a></code></td> - <td>重复伯努利试验,直到出现某一结果的试验次数</td> + <td>几何分布:重复伯努利试验,直到出现某一结果的试验次数</td> <td>抛掷骰子,记录“6”首次出现时的试验次数</td> </tr> @@ -116,7 +116,7 @@ <td><code><a href= "#exponential_distribution">exponential_distribution</a></code></td> - <td>质数分布</td> + <td>指数分布</td> <td>放射性物质发射 alpha 粒子的间隔时间</td> </tr> @@ -143,7 +143,7 @@ <td><code><a href= "#uniform_on_sphere">uniform_on_sphere</a></code></td> - <td>多维空间的单位球面上的均匀分布</td> + <td>任意给定维数空间的单位球面上的均匀分布</td> <td>在地球 (近似看作是球体) 表面任选一点去旅游</td> </tr> @@ -154,11 +154,11 @@ <ul> <li>内部随机数源</li> - <li>(若适用) 返回类型,其默认值为一合适的类型</li> + <li>返回类型,其默认值为一合适的类型 (可能无这一参数)</li> </ul> - <p><em>The distribution functions no longer satisfy the input iterator- requirements (std:24.1.1 [lib.input.iterators]), because this is redundant + <p><em>分布函数不再满足输入迭代器 (input iterator) 的需求 (std:24.1.1 [lib.input.iterators]),
+ because this is redundantgiven the Generator interface and imposes a run-time overhead on all users.
Moreover, a Generator interface appeals to random number generation as being more "natural". Use an <a href= @@ -227,17 +227,16 @@ <h3>描述</h3>- <p>分布函数 <code>uniform_smallint</code> 是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。每次调用都将返 回在整数集 {min, min+1, min+2, ..., max} 上均匀分布的随机整数。它假设目的区 间长度 (max-min+1) 比内部随机数源小得多,因此不考虑量子化问题。</p> + <p>分布函数 <code>uniform_smallint</code> 是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。每次调用都将返 回在整数集 {min, min+1, min+2, ..., max} 上均匀分布的随机整数。它假设目的区 间长度 (max-min+1) 比内部随机数源小得多,因此不考虑量子化 (quantization) 问 题。</p>
- <p>令 r<sub>out</sub>=(max-min+1) 为目的区间 (或其长度 ),r<sub>base</sub> 为随机数源的区间 (或其长度)。于是对于均匀分 布,r<sub>out</sub> 中任意数 i 的理论概率为 p<sub>out</sub>(i) = 1/r<sub>out</sub>。类似地,今内部随机数源产生 r<sub>base</sub> 上的均匀分 布,故有 p<sub>base</sub>(i) = 1/r<sub>base</sub>。令 p<sub>out_s</sub>(i) 为 <code>uniform_smallint</code> 对应的分布函数。对 r<sub>out</sub> 中的各 i ,(p<sub>out_s</sub>(i)/p<sub>out</sub>(i) -1)<sup>2</sup> 的和应不大于 r<sub>out</sub>/r<sub>base</sub><sup>2</sup> (r<sub>base</sub> mod + <p>令 r<sub>out</sub>=(max-min+1) 为目的区间 (或其长度 ),r<sub>base</sub> 为随机数源的区间 (或其长度)。今要求产生一均匀分布,即 r<sub>out</sub> 中任意数 i 的理论概率为 p<sub>out</sub>(i) = 1/r<sub>out</sub>。类似地,内部随机数源产生 r<sub>base</sub> 上的均匀分 布,故有 p<sub>base</sub>(i) = 1/r<sub>base</sub>。令概率函数 p<sub>out_s</sub>(i) 描述 <code>uniform_smallint</code> 实际产生的分布函数。 对 r<sub>out</sub> 中的各 i ,(p<sub>out_s</sub>(i)/p<sub>out</sub>(i) -1)<sup>2</sup> 的和应不大于 r<sub>out</sub>/r<sub>base</sub><sup>2</sup> (r<sub>base</sub> mod
r<sub>out</sub>)(r<sub>out</sub> - r<sub>base</sub> mod r<sub>out</sub>)。</p> <p>模板参数 <code>IntType</code> 应为一类整数的值类型。</p> - <p><em>Note:</em> The property above is the square sum of the relative - differences in probabilities between the desired uniform distribution- p<sub>out</sub>(i) and the generated distribution p<sub>out_s</sub>(i). The + <p><em>注记:</em>上述和式是要求的分布函数 p<sub>out</sub>(i) 和实际产生 的分布函数 p<sub>out_s</sub>(i) 中各数概率相对差的平方和。
+ The property can be fulfilled with the calculation (base_rng modr<sub>out</sub>), as follows: Let r = r<sub>base</sub> mod r<sub>out</sub>.
The base distribution on r<sub>base</sub> is folded onto the range @@ -346,13 +345,13 @@<p>分布函数 <code>uniform_01</code> 是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。每次调用都将返 回在区间 [0...1) 上均匀分布的随机浮点数。这一数值是用 <code>std::numeric_limits<RealType>::digits</code> 个随机二进制位构造 而成的,也即浮点数的尾数全都是随机的二进制位。[<em>注记:</em>是否要使这一行 为可配置?]</p>
- <p><em>警告:</em>因为偶然的历史原因,此类的构造函数取一 UniformRandomNumberGenerator,且<strong>传值</strong>。通常需要的是引用语 义,从而生成器就地改变,而不是复制;如果需要引用语义,用引用类型作为 UniformRandomNumberGenerator 的模板参数。</p> + <p><em>警告:</em>因为偶然的历史原因,此类的构造函数取一 UniformRandomNumberGenerator,且 <strong>传值</strong>。通常需要的是引用语 义,从而生成器可以被“就地”地修改;如果需要引用语义,用引用类型作为 UniformRandomNumberGenerator 的模板参数。</p>
<p>模板参数 <code>RealType</code> 应为一类浮点的值类型,支持双目运算符 +, - 和 /。<code>rng.max()-rng.min()+1</code> 的值必须在其可表示范围内。</p>
<p><code>base_type::result_type</code> 必须为一类数字的值类型,必须支持 到 <code>RealType</code> 的 <code>static_cast<></code>和双目运算符 -。 </p>
- <p><em>注意:</em>当前的实现是有 bug 的,因为在某些情况下不会把尾数全部填 充为随机的二进制位。目前尚不知道如何把 (尚未发明的) <code>boost::bigfloat</code> 类有效地用随机位填满。可能需要一个 traits 类 了。</p> + <p><em>注意:</em>当前的实现是有 bug 的,因为在某些情况下不会把尾数全部填 充为随机的二进制位。目前尚不知道如何把 (未实现的) <code>boost::bigfloat</code> 类有效地用随机位填满。可能需要一个 traits 类。 </p>
<h3>成员</h3> <pre> @@ -386,7 +385,7 @@ <h3>描述</h3>- <p>分布函数 <code>uniform_real</code> 是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。每次调用都将返 回在区间 [min..max) 上均匀分布的随机浮点数。这一数值是用 <code>std::numeric_limits<RealType>::digits</code> 个随机二进制位,也 即浮点数的尾数全都是随机的二进制位。</p> + <p>分布函数 <code>uniform_real</code> 是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。每次调用都将返 回在区间 [min..max) 上均匀分布的随机浮点数。这一数值是用 <code>std::numeric_limits<RealType>::digits</code> 个随机二进制位构造 而成的,也即浮点数的尾数全都是随机的二进制位。</p>
<p><em>注意:</em>当前的实现是有 bug 的,因为在某些情况下不会把尾数全部填 充为随机的二进制位。</p>
@@ -688,5 +687,11 @@ accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a href= "http://www.boost.org/LICENSE_1_0.txt";>http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> + <p>中文版修订:2009/1/25</p> ++ <p><i>Copyright © 2008 <a href="http://wiki.woodpecker.org.cn/moin/XiaoQi";>xiaq</a></i></p>
++ <p><i>在 Boost Software License, Version 1.0 的条款下发布。(参看文件 <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> 或在线副本 <a href="http://www.boost.org/LICENSE_1_0.txt";> http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
+ </body> </html> Modified: trunk/libs/random/random-generators.html ============================================================================== --- trunk/libs/random/random-generators.html (original) +++ trunk/libs/random/random-generators.html Sun Jan 25 18:51:10 2009 @@ -747,7 +747,7 @@2005 年 4 月发现算法的一个 <a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html";>缺 陷</a> 后修改了用整数赋种的方法。<br>
此生成器的品质很大程度上取决于参数的选择。用户代码应该使用已经选择好参数 的生成器,如 <code>mt19937</code>。<br> - 此生成器需要的内存是可观的。例如 <code>mt11213b</code> 需要约 1408 bytes 内存,而 <code>mt19937</code> 需要约 2496 bytes。 + 此生成器的状态数组需要的内存是可观的。例如 <code>mt11213b</code> 需要约 1408 bytes 内存,而 <code>mt19937</code> 需要约 2496 bytes。
<h3>构造函数</h3> <pre> @@ -846,14 +846,8 @@ pp. 704-706. </blockquote> - <p><em>Note:</em> The quality of the generator crucially depends on the - choice of the parameters. User code should employ one of the sensibly - parameterized generators such as <code>lagged_fibonacci607</code> - instead.<br> - The generator requires considerable amounts of memory for the storage of - its state array. For example, <code>lagged_fibonacci607</code> requires- about 4856 bytes and <code>lagged_fibonacci44497</code> requires about 350
- KBytes.</p>+ <p><em>注意:</em>此生成器的品质很大程度上取决于参数的选择。用户代码应该 使用已经选择好参数的生成器,如 <code>lagged_fibonacci607</code>。<br> + 此生成器的状态数组需要的内存是可观的。例如 <code>lagged_fibonacci607</code> 需要约 4856 bytes 内存,而 <code>lagged_fibonacci44497</code> 需要约 350 KBytes。</p>
<h3>构造函数</h3> <pre> Modified: trunk/libs/random/random-variate.html ============================================================================== --- trunk/libs/random/random-variate.html (original) +++ trunk/libs/random/random-variate.html Sun Jan 25 18:51:10 2009 @@ -86,47 +86,39 @@ template<class T> result_type operator()(T value) </pre>- <p><strong>Returns:</strong> <code>distribution()(e, value)</code>. For the
- semantics of <code>e</code>, see the description of - <code>operator()()</code>.</p>+ <p><strong>返回:</strong> <code>distribution()(e, value)</code>。 <code>e</code> 的语义已在 <code>operator()()</code> 的描述中给出。</p>
<pre> engine_value_type& engine() </pre> - <p><strong>Returns:</strong> A reference to the associated uniform random - number generator.</p> + <p><strong>返回:</strong>相关均匀随机数生成器的引用。</p> <pre> const engine_value_type& engine() const </pre> - <p><strong>Returns:</strong> A reference to the associated uniform random - number generator.</p> + <p><strong>返回:</strong>相关均匀随机数生成器的引用。</p> <pre> distribution_type& distribution() </pre> - <p><strong>Returns:</strong> A reference to the associated random - distribution.</p> + <p><strong>返回:</strong>相关分布的引用。</p> <pre> const distribution_type& distribution() const </pre> - <p><strong>Returns:</strong> A reference to the associated random - distribution.</p> + <p><strong>返回:</strong>相关分布的引用。</p> <pre> result_type min() const </pre> - <p><strong>Precondition:</strong> <code>distribution().min()</code> is - well-formed<br> - <strong>Returns:</strong> <code>distribution().min()</code></p> + <p><strong>前条件:</strong> <code>distribution().min()</code>有定义<br> + <strong>返回:</strong> <code>distribution().min()</code></p> <pre> result_type max() const </pre> - <p><strong>Precondition:</strong> <code>distribution().max()</code> is - well-formed<br> - <strong>Returns:</strong> <code>distribution().max()</code></p> + <p><strong>前条件:</strong> <code>distribution().max()</code> 有定义<br> + <strong>返回:</strong> <code>distribution().max()</code></p> <hr><p><a href="http://validator.w3.org/check?uri=referer";><img border="0" src=
@@ -144,11 +136,11 @@ accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a href= "http://www.boost.org/LICENSE_1_0.txt";>http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> - <p>中文版修订:2008/7/2</p> + <p>中文版修订:2009/1/25</p><p><i>Copyright © 2008 <a href="http://wiki.woodpecker.org.cn/moin/XiaoQi";>xiaq</a></i></p>
- <p><i>在 Boost Software License, Version 1.0 的条款下发布。(参看文件 <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> 或在线副本 <a href="http://www.boost.org/LICENSE_1_0.txt";> http://www.boost.org/LICENSE_1_0.txt</a>)</i></p> + <p><i>在 Boost Software License, Version 1.0 的条款下发布。(参看文件 <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> 或在线副本 <a href="http://www.boost.org/LICENSE_1_0.txt";> http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
</body> </html>