Author: alai04 Date: Fri Feb 13 06:52:56 2009 New Revision: 211 Modified: trunk/libs/random/random-distributions.html trunk/libs/random/random-misc.html trunk/libs/random/random-variate.html Log: 补充random库中的一些未译段落。 Modified: trunk/libs/random/random-distributions.html ============================================================================== --- trunk/libs/random/random-distributions.html (original) +++ trunk/libs/random/random-distributions.html Fri Feb 13 06:52:56 2009 @@ -1,13 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> - -<html> -<head> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <title>Boost 随机数库:分布</title> -</head> + <title>Boost 随机数库:分布</title></head> + -<body bgcolor="#FFFFFF" text="#000000"> +<body bgcolor="#ffffff" text="#000000"> <h1>随机数库:分布</h1> <ul> @@ -42,10 +40,13 @@<p>除了 <a href="random-generators.html">随机数生成器</a> 之外,本库还提 供了把一种分布 (通常是生成器产生的均匀分布) 映射到另一种分布的分布函数。(译 注:在本节中,"分布"指统计学意义上的分布,而"分布函数"指的是类模板。内部的随 机数生成器有时会更一般地被称为"随机数源"。)</p>
- <p>对于某一映射通常会有多种实现方案:有的需要较多的空间和对内部随机数源的 调用,而有的需要进行较多的费时的运算 (如三角函数)。以下给出的对接口的描述是 与具体实现无关的;然而,如果某一实现不能覆盖特定分布的全部值域,或者不符合该 分布的统计学性质,该实现是无效的。</p>
+ <p>对+于某一映射通常会有多种实现方案:有的需要较多的空间和对内部随机数源的调 用,而有的需要进行较多的费时的运算 +(如三角函数)。以下给出的对接口的描述是与具体实现无关的;然而,如果某一实现 不能覆盖特定分布的全部值域,或者不符合该分布的统计学性质,该实现是无
+效的。</p> - <table border="1" summary=""> - <tr> + <table summary="" border="1"> + <tbody><tr> <th>分布</th> <th>描述</th> @@ -86,8 +87,7 @@ </tr> <tr> - <td><code><a href= - "#bernoulli_distribution">bernoulli_distribution</a></code></td>+ <td><code><a href="#bernoulli_distribution">bernoulli_distribution</a></code></td>
<td>伯努利试验 (Bernoulli experiment):布尔离散分布,概率可配置</td> @@ -95,8 +95,7 @@ </tr> <tr> - <td><code><a href= - "#geometric_distribution">geometric_distribution</a></code></td>+ <td><code><a href="#geometric_distribution">geometric_distribution</a></code></td>
<td>几何分布:重复伯努利试验,直到出现某一结果的试验次数</td> @@ -104,8 +103,7 @@ </tr> <tr> - <td><code><a href= - "#triangle_distribution">triangle_distribution</a></code></td>+ <td><code><a href="#triangle_distribution">triangle_distribution</a></code></td>
<td>?</td> @@ -113,8 +111,7 @@ </tr> <tr> - <td><code><a href= - "#exponential_distribution">exponential_distribution</a></code></td>+ <td><code><a href="#exponential_distribution">exponential_distribution</a></code></td>
<td>指数分布</td> @@ -122,8 +119,7 @@ </tr> <tr> - <td><code><a href= - "#normal_distribution">normal_distribution</a></code></td>+ <td><code><a href="#normal_distribution">normal_distribution</a></code></td>
<td>无穷次重复伯努利试验的结果计数</td> @@ -131,8 +127,7 @@ </tr> <tr> - <td><code><a href= - "#lognormal_distribution">lognormal_distribution</a></code></td>+ <td><code><a href="#lognormal_distribution">lognormal_distribution</a></code></td>
<td>对数正态分布 (lognormal distribution) (有时用于模拟)</td> @@ -140,14 +135,13 @@ </tr> <tr> - <td><code><a href= - "#uniform_on_sphere">uniform_on_sphere</a></code></td>+ <td><code><a href="#uniform_on_sphere">uniform_on_sphere</a></code></td>
<td>任意给定维数空间的单位球面上的均匀分布</td> <td>在地球 (近似看作是球体) 表面任选一点去旅游</td> </tr> - </table> + </tbody></table> <p>分布函数的模板参数总按照下列顺序排列:</p> @@ -157,73 +151,24 @@ <li>返回类型,其默认值为一合适的类型 (可能无这一参数)</li> </ul>- <p><em>分布函数不再满足输入迭代器 (input iterator) 的需求 (std:24.1.1 [lib.input.iterators]),
- because this is redundant- given 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=- "../utility/iterator_adaptors.htm">iterator adaptor</a> if you need to wrap
- any of the generators in an input iterator interface.</em></p> -- <p>下面描述的所有分布函数都保存对随机数源的一个非 const 引用;因此分布函 数不是 Assignable;不过它们是 CopyConstructible。复制分布函数将会复制参数 值;副本和原分布函数将会使用同一内部随机数源,因此两者会从同一序列中取得随机 数。</p>
+ <p><em>分 +布函数不再满足输入迭代器 (input iterator) 的需求 (std:24.1.1+[lib.input.iterators]),因为这对于生成器(Generator)接口来说是多余的,还会对 所有用户带来运行时的开销。而且,一个 +诉诸于随机数生成的生成器接口更为"自然"。如果你需要把生成器包装进一个输入迭 代器接口,可以使用 <a href="../utility/iterator_adaptors.htm">迭代器适配器 (iterator adaptor)</a>。</em></p>
+ + <p>下+面描述的所有分布函数都保存对随机数源的一个非 const 引用;因此分布函数不是 Assignable;不过它们是 +CopyConstructible。复制分布函数将会复制参数值;副本和原分布函数将会使用同一 内部随机数源,因此两者会从同一序列中取得随机数。</p>
<p>对于在 <a href="random-concepts.html">概念文档</a> 中已经给出定义的成 员,在下面的描述中不会详细说明。</p>
<h2><code><boost/random.hpp></code> 中的分布:<a name="synopsis" id="synopsis">概览</a></h2>
- <pre> -namespace boost { - template<class IntType = int> - class uniform_smallint; - template<class IntType = int> - class uniform_int; - template<class RealType = double> - class uniform_01; - template<class RealType = double> - class uniform_real; - - // discrete distributions - template<class RealType = double> - class bernoulli_distribution; - template<class IntType = int> - class geometric_distribution; - - // continuous distributions - template<class RealType = double> - class triangle_distribution; - template<class RealType = double> - class exponential_distribution; - template<class RealType = double> - class normal_distribution; - template<class RealType = double> - class lognormal_distribution; - template<class RealType = double, - class Cont = std::vector<RealType> > - class uniform_on_sphere; -} -</pre>+ <pre>namespace boost {<br> template<class IntType = int><br> class uniform_smallint;<br> template<class IntType = int><br> class uniform_int;<br> template<class RealType = double><br> class uniform_01;<br> template<class RealType = double><br> class uniform_real;<br><br> // discrete distributions<br> template<class RealType = double><br> class bernoulli_distribution;<br> template<class IntType = int><br> class geometric_distribution;<br><br> // continuous distributions<br> template<class RealType = double><br> class triangle_distribution;<br> template<class RealType = double><br> class exponential_distribution;<br> template<class RealType = double><br> class normal_distribution;<br> template<class RealType = double><br> class lognormal_distribution;<br> template<class RealType = double,<br> class Cont = std::vector<RealType> ><br> class uniform_on_sphere;<br>}<br></pre>
<h2><a name="uniform_smallint" id="uniform_smallint"><code>uniform_smallint</code> 类模板</a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/uniform_smallint.hpp">boost/random/uniform_smallint.hpp</a>> - -template<class IntType = int> -class uniform_smallint -{ -public: - typedef IntType input_type; - typedef IntType result_type; - static const bool has_fixed_range = false; - uniform_smallint(IntType min, IntType max); - result_type min() const; - result_type max() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/uniform_smallint.hpp">boost/random/uniform_smallint.hpp</a>><br><br>template<class IntType = int><br>class uniform_smallint<br>{<br>public:<br> typedef IntType input_type;<br> typedef IntType result_type;<br> static const bool has_fixed_range = false;<br> uniform_smallint(IntType min, IntType max);<br> result_type min() const;<br> result_type max() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3> @@ -235,59 +180,28 @@ <p>模板参数 <code>IntType</code> 应为一类整数的值类型。</p>- <p><em>注记:</em>上述和式是要求的分布函数 p<sub>out</sub>(i) 和实际产生 的分布函数 p<sub>out_s</sub>(i) 中各数概率相对差的平方和。
- The - property can be fulfilled with the calculation (base_rng mod- r<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 - r<sub>out</sub>. The numbers i < r have assigned (r<sub>base</sub> div - r<sub>out</sub>)+1 numbers of the base distribution, the rest has only - (r<sub>base</sub> div r<sub>out</sub>). Therefore, p<sub>out_s</sub>(i) =- ((r<sub>base</sub> div r<sub>out</sub>)+1) / r<sub>base</sub> for i < r
- and p<sub>out_s</sub>(i) = (r<sub>base</sub> div- r<sub>out</sub>)/r<sub>base</sub> otherwise. Substituting this in the above
- sum formula leads to the desired result.</p> - - <p><em>Note:</em> The upper bound for (r<sub>base</sub> mod- r<sub>out</sub>)(r<sub>out</sub> - r<sub>base</sub> mod r<sub>out</sub>) is - r<sub>out</sub><sup>2</sup>/4. Regarding the upper bound for the square sum
- of the relative quantization error of- r<sub>out</sub><sup>3</sup>/(4*r<sub>base</sub><sup>2</sup>), it seems wise
- to either choose r<sub>base</sub> so that r<sub>base</sub> >- 10*r<sub>out</sub><sup>2</sup> or ensure that r<sub>base</sub> is divisible
- by r<sub>out</sub>.</p> - - <h3>成员</h3> - <pre> -uniform_smallint(IntType min, IntType max) -</pre>+ <p><em>注记:</em>上述和式是要求的分布函数 p<sub>out</sub>(i) 和实际产生 的分布函数 p<sub>out_s</sub>(i) 中各数概率相对差的平方和。其值可由计算 (base_rng mod + r<sub>out</sub>) 来得到,如下:令 r = r<sub>base</sub> mod r<sub>out</sub>。r<sub>base</sub> 上的基础分布被折叠到区间 r<sub>out</sub> 上。数字 i < r 快已被赋以基础分布的 (r<sub>base</sub> div
+ r<sub>out</sub>)+1 个数字,只剩下+ (r<sub>base</sub> div r<sub>out</sub>)。因此,对于 i < r,p<sub>out_s</sub>(i) = + ((r<sub>base</sub> div r<sub>out</sub>)+1) / r<sub>base</sub>,而对于其 它 i,p<sub>out_s</sub>(i) = (r<sub>base</sub> div + r<sub>out</sub>)/r<sub>base</sub>。在以上求和公式中替换这一部分,可得到希 望的结果。</p>
+ + <p><em>注记:</em>(r<sub>base</sub> mod+ r<sub>out</sub>)(r<sub>out</sub> - r<sub>base</sub> mod r<sub>out</sub>) 的上限是
+ r<sub>out</sub><sup>2</sup>/4。对于+ r<sub>out</sub><sup>3</sup>/(4*r<sub>base</sub><sup>2</sup>) 的相对量化误 差的平方和的上限, 明智的方法是,要么选择一个满足 r<sub>base</sub> > + 10*r<sub>out</sub><sup>2</sup> 的 r<sub>base</sub><sup></sup>,要么确保 r<sub>base</sub> 可被 r<sub>out</sub> 整除。</p>
+ + <h3>成员</h3> + <pre>uniform_smallint(IntType min, IntType max)<br></pre><p><strong>效果:</strong>构造一 <code>uniform_smallint</code> 函子。 <code>min</code> 和 <code>max</code> 分别为输出值域的上下界。</p>
<h2><a name="uniform_int" id="uniform_int"><code>uniform_int</code> 类模 板</a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/uniform_int.hpp">boost/random/uniform_int.hpp</a>> - -template<class IntType = int> -class uniform_int -{ -public: - typedef IntType input_type; - typedef IntType result_type; - static const bool has_fixed_range = false; - explicit uniform_int(IntType min = 0, IntType max = 9); - result_type min() const; - result_type max() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); - template<class UniformRandomNumberGenerator>- result_type operator()(UniformRandomNumberGenerator& urng, result_type n);
-}; -</pre>+ <pre>#include <<a href="../../boost/random/uniform_int.hpp">boost/random/uniform_int.hpp</a>><br><br>template<class IntType = int><br>class uniform_int<br>{<br>public:<br> typedef IntType input_type;<br> typedef IntType result_type;<br> static const bool has_fixed_range = false;<br> explicit uniform_int(IntType min = 0, IntType max = 9);<br> result_type min() const;<br> result_type max() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng, result_type n);<br>};<br></pre>
<h3>描述</h3> @@ -296,50 +210,24 @@ <p>模板参数 <code>IntType</code> 应为一类整数的值类型。</p> <h3>成员</h3> - <pre> - uniform_int(IntType min = 0, IntType max = 9) -</pre> + <pre> uniform_int(IntType min = 0, IntType max = 9)<br></pre> <p><strong>需求:</strong> min <= max<br><strong>效果:</strong>构造一 <code>uniform_int</code> 对象。 <code>min</code> 和 <code>max</code> 为分布的参数。</p>
- <pre> - result_type min() const -</pre> + <pre> result_type min() const<br></pre> <p><strong>返回:</strong>分布的 "min" 参数。</p> - <pre> - result_type max() const -</pre> + <pre> result_type max() const<br></pre> <p><strong>返回:</strong>分布的 "max" 参数。</p> - <pre>- result_type operator()(UniformRandomNumberGenerator& urng, result_type n)
-</pre> -- <p><strong>返回:</strong>在值域 0 <= x < n 内均匀分布的随机数 x。 <em>[注记:This allows a <code>variate_generator</code> object
- with a <code>uniform_int</code> distribution to be used with - std::random_shuffe, see [lib.alg.random.shuffle]. ]</em></p>+ <pre> result_type operator()(UniformRandomNumberGenerator& urng, result_type n)<br></pre>
++ <p><strong>返回:</strong>在值域 0 <= x < n 内均匀分布的随机数 x。 <em>[注记:可以将一个带有</em><em> <code>uniform_int</code></em><em> 分布的 <code>variate_generator</code> 对象用于 std::random_shuffe,请见 [lib.alg.random.shuffle]. ]</em></p>
<h2><a name="uniform_01" id="uniform_01"><code>uniform_01</code> 类模板 </a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/uniform_01.hpp">boost/random/uniform_01.hpp</a>> - -template<class UniformRandomNumberGenerator, class RealType = double> -class uniform_01 -{ -public: - typedef UniformRandomNumberGenerator base_type; - typedef RealType result_type; - static const bool has_fixed_range = false; - explicit uniform_01(base_type rng); - result_type operator()(); - result_type min() const; - result_type max() const; -}; -</pre>+ <pre>#include <<a href="../../boost/random/uniform_01.hpp">boost/random/uniform_01.hpp</a>><br><br>template<class UniformRandomNumberGenerator, class RealType = double><br>class uniform_01<br>{<br>public:<br> typedef UniformRandomNumberGenerator base_type;<br> typedef RealType result_type;<br> static const bool has_fixed_range = false;<br> explicit uniform_01(base_type rng);<br> result_type operator()();<br> result_type min() const;<br> result_type max() const;<br>};<br></pre>
<h3>描述</h3> @@ -354,34 +242,14 @@<p><em>注意:</em>当前的实现是有 bug 的,因为在某些情况下不会把尾数全部填 充为随机的二进制位。目前尚不知道如何把 (未实现的) <code>boost::bigfloat</code> 类有效地用随机位填满。可能需要一个 traits 类。 </p>
<h3>成员</h3> - <pre> -explicit uniform_01(base_type rng) -</pre> + <pre>explicit uniform_01(base_type rng)<br></pre><p><strong>效果:</strong>构造一 <code>uniform_01</code> 函子,使用给定的 随机数生成器作为内部随机数源。</p>
<h2><a name="uniform_real" id="uniform_real"><code>uniform_real</code> 类 模板</a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/uniform_real.hpp">boost/random/uniform_real.hpp</a>> - -template<class RealType = double> -class uniform_real -{ -public: - typedef RealType input_type; - typedef RealType result_type; - static const bool has_fixed_range = false; - uniform_real(RealType min = RealType(0), RealType max = RealType(1)); - result_type min() const; - result_type max() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/uniform_real.hpp">boost/random/uniform_real.hpp</a>><br><br>template<class RealType = double><br>class uniform_real<br>{<br>public:<br> typedef RealType input_type;<br> typedef RealType result_type;<br> static const bool has_fixed_range = false;<br> uniform_real(RealType min = RealType(0), RealType max = RealType(1));<br> result_type min() const;<br> result_type max() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3> @@ -390,123 +258,57 @@<p><em>注意:</em>当前的实现是有 bug 的,因为在某些情况下不会把尾数全部填 充为随机的二进制位。</p>
<h3>成员</h3> - <pre> - uniform_real(RealType min = RealType(0), RealType max = RealType(1)) -</pre>+ <pre> uniform_real(RealType min = RealType(0), RealType max = RealType(1))<br></pre>
<p><strong>需求:</strong> min <= max<br><strong>效果:</strong>构造一 <code>uniform_real</code> 对象。 <code>min</code> 和 <code>max</code> 是分布的参数。</p>
- <pre> - result_type min() const -</pre> + <pre> result_type min() const<br></pre> <p><strong>返回:</strong>分布的 "min" 参数。</p> - <pre> - result_type max() const -</pre> + <pre> result_type max() const<br></pre> <p><strong>返回:</strong>分布的 "max" 参数。</p><h2><a name="bernoulli_distribution" id="bernoulli_distribution"><code>bernoulli_distribution</code> 类模板 </a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/bernoulli_distribution.hpp">boost/random/bernoulli_distribution.hpp</a>> - -template<class RealType = double> -class bernoulli_distribution -{ -public: - typedef int input_type; - typedef bool result_type; - - explicit bernoulli_distribution(const RealType& p = RealType(0.5)); - RealType p() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/bernoulli_distribution.hpp">boost/random/bernoulli_distribution.hpp</a>><br><br>template<class RealType = double><br>class bernoulli_distribution<br>{<br>public:<br> typedef int input_type;<br> typedef bool result_type;<br><br> explicit bernoulli_distribution(const RealType& p = RealType(0.5));<br> RealType p() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3><p><code>bernoulli_distribution</code> 类模板的实例是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。此分布产生 <code>bool</code> 值,概率满足 P(true) = p 且 P(false) = 1-p。p 是分布的参 数。</p>
<h3>成员</h3> - <pre> - bernoulli_distribution(const RealType& p = RealType(0.5)) -</pre>+ <pre> bernoulli_distribution(const RealType& p = RealType(0.5))<br></pre>
<p><strong>需求:</strong> 0 <= p <= 1<br><strong>效果:</strong>构造一 <code>bernoulli_distribution</code> 对象。 <code>p</code> 是分布的参数。</p>
- <pre> - RealType p() const -</pre> + <pre> RealType p() const<br></pre> <p><strong>返回:</strong>分布的 "p" 参数。</p><h2><a name="geometric_distribution" id="geometric_distribution"><code>geometric_distribution</code> 类模板 </a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/geometric_distribution.hpp">boost/random/geometric_distribution.hpp</a>> - -template<class UniformRandomNumberGenerator, class IntType = int> -class geometric_distribution -{ -public: - typedef RealType input_type; - typedef IntType result_type; - - explicit geometric_distribution(const RealType& p = RealType(0.5)); - RealType p() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/geometric_distribution.hpp">boost/random/geometric_distribution.hpp</a>><br><br>template<class UniformRandomNumberGenerator, class IntType = int><br>class geometric_distribution<br>{<br>public:<br> typedef RealType input_type;<br> typedef IntType result_type;<br><br> explicit geometric_distribution(const RealType& p = RealType(0.5));<br> RealType p() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3><p><code>geometric_distribution</code> 类模板的实例是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。对整数 <em>i</em> >= 1,产生 i 的概率 p(i) = (1-p) * p<sup>i-1</sup>,其中 p 是 分布的参数。对 UniformRandomNumberGenerator 的每次调用应产生在 [0,1) 上均匀 分布的浮点数。</p>
<h3>成员</h3> - <pre> - geometric_distribution(const RealType& p = RealType(0.5)) -</pre>+ <pre> geometric_distribution(const RealType& p = RealType(0.5))<br></pre>
<p><strong>需求:</strong> 0 < p < 1<br><strong>效果:</strong>构造一 <code>geometric_distribution</code> 对象。 <code>p</code> 是分布的参数。</p>
- <pre> - RealType p() const -</pre> + <pre> RealType p() const<br></pre> <p><strong>返回:</strong>分布的 "p" 参数。</p><h2><a name="triangle_distribution" id="triangle_distribution"><code>triangle_distribution</code> 类模板 </a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/triangle_distribution.hpp">boost/random/triangle_distribution.hpp</a>> - -template<class RealType = double> -class triangle_distribution -{ -public: - typedef RealType input_type; - typedef RealType result_type; - triangle_distribution(result_type a, result_type b, result_type c); - result_type a() const; - result_type b() const; - result_type c() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/triangle_distribution.hpp">boost/random/triangle_distribution.hpp</a>><br><br>template<class RealType = double><br>class triangle_distribution<br>{<br>public:<br> typedef RealType input_type;<br> typedef RealType result_type;<br> triangle_distribution(result_type a, result_type b, result_type c);<br> result_type a() const;<br> result_type b() const;<br> result_type c() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3> @@ -514,184 +316,95 @@<= c</code>; <code>x</code> 服从三角形分布 (triangle distribution),其 中 <code>b</code> 为密度最大的点。对 UniformRandomNumberGenerator 的每次调用 应产生在 [0,1) 上均匀分布的浮点数。</p>
<h3>成员</h3> - <pre> -triangle_distribution(result_type a, result_type b, result_type c) -</pre>+ <pre>triangle_distribution(result_type a, result_type b, result_type c)<br></pre>
<p><strong>效果:</strong>构造一 <code>triangle_distribution</code> 函 子。<code>a, b, c</code> 是分布的参数。</p>
<h2><a name="exponential_distribution" id="exponential_distribution"><code>exponential_distribution</code> 类模板 </a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/exponential_distribution.hpp">boost/random/exponential_distribution.hpp</a>> - -template<class RealType = double> -class exponential_distribution -{ -public: - typedef RealType input_type; - typedef RealType result_type; - explicit exponential_distribution(const result_type& lambda); - RealType lambda() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/exponential_distribution.hpp">boost/random/exponential_distribution.hpp</a>><br><br>template<class RealType = double><br>class exponential_distribution<br>{<br>public:<br> typedef RealType input_type;<br> typedef RealType result_type;<br> explicit exponential_distribution(const result_type& lambda);<br> RealType lambda() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3>- <p><code>exponential_distribution</code> 类模板的实例是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。对实数 x > 0,其密度 p(x) = lambda * exp(-lambda * x),其中 lambda 是分布的参数。对 UniformRandomNumberGenerator 的每次调用应产生在 [0,1) 上均匀分布的浮点数。 </p>
- - <h3>成员</h3> - <pre>- exponential_distribution(const result_type& lambda = result_type(1))
-</pre>+ <p><code>exponential_distribution</code> 类模板的实例是 <a href="random-concepts.html#random-dist">随机分布</a> +的模型。对实数 x > 0,其密度 p(x) = lambda * exp(-lambda * x),其中 lambda +是分布的参数。对 UniformRandomNumberGenerator 的每次调用应产生在 [0,1) 上均 匀分布的浮点数。</p>
+ + <h3>成员</h3>+ <pre> exponential_distribution(const result_type& lambda = result_type(1))<br></pre>
<p><strong>需求:</strong> lambda > 0<br><strong>效果:</strong>构造一 <code>exponential_distribution</code> 对 象。<code>lambda</code> 是分布的参数。</p>
- <pre> - RealType lambda() const -</pre> + <pre> RealType lambda() const<br></pre> <p><strong>返回:</strong>分布的 "lambda" 参数。</p><h2><a name="normal_distribution" id="normal_distribution"><code>normal_distribution</code> 类模板</a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/normal_distribution.hpp">boost/random/normal_distribution.hpp</a>> - -template<class RealType = double> -class normal_distribution -{ -public: - typedef RealType input_type; - typedef RealType result_type; - explicit normal_distribution(const result_type& mean = 0, - const result_type& sigma = 1); - RealType mean() const; - RealType sigma() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/normal_distribution.hpp">boost/random/normal_distribution.hpp</a>><br><br>template<class RealType = double><br>class normal_distribution<br>{<br>public:<br> typedef RealType input_type;<br> typedef RealType result_type;<br> explicit normal_distribution(const result_type& mean = 0,<br> const result_type& sigma = 1);<br> RealType mean() const;<br> RealType sigma() const;<br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3><p><code>normal_distribution</code> 类模板的实例是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。对任意实数 x,其密度 p(x) = 1/sqrt(2*pi*sigma) * exp(- (x-mean)<sup>2</sup> / (2*sigma<sup>2</sup>) ),其中 mean 和 sigma 是分布的参数。对 UniformRandomNumberGenerator 的每次调用应产生在 [0,1) 上均匀分布的浮点数。 </p>
<h3>成员</h3> - <pre> - explicit normal_distribution(const result_type& mean = 0, - const result_type& sigma = 1); -</pre>+ <pre> explicit normal_distribution(const result_type& mean = 0,<br> const result_type& sigma = 1);<br></pre>
<p><strong>需求:</strong> sigma > 0<br><strong>效果:</strong>构造一 <code>normal_distribution</code>。 <code>mean</code> 和 <code>sigma</code> 是分布的参数。</p>
- <pre> - RealType mean() const -</pre> + <pre> RealType mean() const<br></pre> <p><strong>返回:</strong>分布的 "mean" 参数。</p> - <pre> - RealType sigma() const -</pre> + <pre> RealType sigma() const<br></pre> <p><strong>返回:</strong>分布的 "sigma" 参数。</p><h2><a name="lognormal_distribution" id="lognormal_distribution"><code>lognormal_distribution</code> 类模板 </a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/lognormal_distribution.hpp">boost/random/lognormal_distribution.hpp</a>> - -template<class RealType = double> -class lognormal_distribution -{ -public: - typedef typename normal_distribution<RealType>::input_type - typedef RealType result_type; - explicit lognormal_distribution(const result_type& mean = 1.0, - const result_type& sigma = 1.0); - RealType& mean() const; - RealType& sigma() const; - void reset(); - template<class UniformRandomNumberGenerator> - result_type operator()(UniformRandomNumberGenerator& urng); -}; -</pre>+ <pre>#include <<a href="../../boost/random/lognormal_distribution.hpp">boost/random/lognormal_distribution.hpp</a>><br><br>template<class RealType = double><br>class lognormal_distribution<br>{<br>public:<br> typedef typename normal_distribution<RealType>::input_type<br> typedef RealType result_type;<br> explicit lognormal_distribution(const result_type& mean = 1.0,<br> const result_type& sigma = 1.0);<br> RealType& mean() const;<br> RealType& sigma() const; <br> void reset();<br> template<class UniformRandomNumberGenerator><br> result_type operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3><p><code>lognormal_distribution</code> 类模板的实例是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。对实数 x > 0,其密度 p(x) = 1/(x * normal_sigma * sqrt(2*pi)) * exp( -(log(x)-normal_mean)<sup>2</sup> / (2*normal_sigma<sup>2</sup>) ),其中 normal_mean = log(mean<sup>2</sup>/sqrt(sigma<sup>2</sup> + mean<sup>2</sup>)) 且 normal_sigma = sqrt(log(1 + sigma<sup>2</sup>/mean<sup>2</sup>))。对 UniformRandomNumberGenerator 的每次 调用应产生在 [0,1) 上均匀分布的浮点数。</p>
<h3>成员</h3> - <pre> -lognormal_distribution(const result_type& mean, - const result_type& sigma) -</pre>+ <pre>lognormal_distribution(const result_type& mean,<br> const result_type& sigma)<br></pre>
<p><strong>效果:</strong>构造一 <code>lognormal_distribution</code> 函 子。<code>mean</code> 和 <code>sigma</code> 是分布的参数。</p>
<h2><a name="uniform_on_sphere" id="uniform_on_sphere"><code>uniform_on_sphere</code> 类模板</a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/uniform_on_sphere.hpp">boost/random/uniform_on_sphere.hpp</a>> - -template<class RealType = double, - class Cont = std::vector<RealType> > -class uniform_on_sphere -{ -public: - typedef RealType input_type; - typedef Cont result_type; - explicit uniform_on_sphere(int dim = 2); - void reset(); - template<class UniformRandomNumberGenerator>- const result_type & operator()(UniformRandomNumberGenerator& urng);
-}; -</pre>+ <pre>#include <<a href="../../boost/random/uniform_on_sphere.hpp">boost/random/uniform_on_sphere.hpp</a>><br><br>template<class RealType = double,<br> class Cont = std::vector<RealType> ><br>class uniform_on_sphere<br>{<br>public:<br> typedef RealType input_type;<br> typedef Cont result_type;<br> explicit uniform_on_sphere(int dim = 2);<br> void reset();<br> template<class UniformRandomNumberGenerator><br> const result_type & operator()(UniformRandomNumberGenerator& urng);<br>};<br></pre>
<h3>描述</h3><p><code>uniform_on_sphere</code> 类模板的实例是 <a href="random-concepts.html#random-dist">随机分布</a> 的模型。这一分布产生在 <code>dim</code> 维空间的单位球面上均匀分布的随机坐标。模板参数 <code>Cont</code> 应为一类 STL 的容器,其 <code>begin</code> 和 <code>end</code> 返回 <code>Cont::iterator</code> 类型的非 const 前向迭代器 (non-const forward iterator)。对 UniformRandomNumberGenerator 的每次调用应产 生在 [0,1) 上均匀分布的浮点数。</p>
<h3>成员</h3> - <pre> -explicit uniform_on_sphere(int dim = 2) -</pre> + <pre>explicit uniform_on_sphere(int dim = 2)<br></pre><p><strong>效果:</strong>构造一 <code>uniform_on_sphere</code> 函子。 <code>dim</code> 是空间的维度。</p>
<hr>- <p><a href="http://validator.w3.org/check?uri=referer";><img border="0" src= - "http://www.w3.org/Icons/valid-html401"; alt="Valid HTML 4.01 Transitional"
- height="31" width="88"></a></p>+ <p><a href="http://validator.w3.org/check?uri=referer";><img src="http://www.w3.org/Icons/valid-html401"; alt="Valid HTML 4.01 Transitional" border="0" height="31" width="88"></a></p>
<p>Revised<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
- <p><i>Copyright © 2000-2007 <a href= - "http://www.boost.org/people/jens_maurer.htm";>Jens Maurer</a></i></p>+ <p><i>Copyright (c) 2000-2007 <a href="http://www.boost.org/people/jens_maurer.htm";>Jens Maurer</a></i></p>
<p><i>Distributed under the Boost Software License, Version 1.0. (See 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>+ 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>Copyright (c) 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> +</body></html> \ No newline at end of file Modified: trunk/libs/random/random-misc.html ============================================================================== --- trunk/libs/random/random-misc.html (original) +++ trunk/libs/random/random-misc.html Fri Feb 13 06:52:56 2009 @@ -1,98 +1,62 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> - -<html> -<head> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <title>Boost 随机数库 (杂项)</title> -</head> + <title>Boost 随机数库 (杂项)</title></head> + -<body bgcolor="#FFFFFF" text="#000000"> - <h1>Random Number Generator Library --- Miscellaneous Decorators</h1> +<body bgcolor="#ffffff" text="#000000"> + <h1>随机数生成器库 --- 杂项:修饰子</h1> <ul> - <li><a href="#random_number_generator">Class template + <li><a href="#random_number_generator">类模板 <code>random_number_generator</code></a></li> </ul> - <h2>Introduction</h2> + <h2>简介</h2> + + <p>这+些修饰子的类模板可以把随机数生成器和分布函数适配为C++标准库中的概念,特别 是 RandomNumberGenerator 和 +InputIterator 概念。后一个概念的适配是很有用的,这是因为,与分布函数相 比,基本的随机数生成器本身并不实现
+InputIterator 的需求。</p> ++ <h2><a name="synopsis" id="synopsis">头文件 </a><code><boost/random.hpp></code> 中的杂项修饰子概要 <code></code></h2> + <pre>namespace boost {<br> template<class UniformRandomNumberGenerator, class IntType = long><br> class random_number_generator;<br>} // namespace boost<br></pre>
++ <h2><a name="random_number_generator" id="random_number_generator">类模 板 <code>random_number_generator</code></a></h2>
+ + <h3>概要</h3>+ <pre>template<class UniformRandomNumberGenerator, class IntType = long><br>class random_number_generator<br>{<br>public:<br> typedef UniformRandomNumberGenerator base_type;<br> typedef IntType argument_type;<br> typedef IntType result_type;<br> random_number_generator(base_type & rng);<br> result_type operator()(argument_type n);<br>};<br></pre>
+ + <h3>说明</h3> + + <p>类模板 <code>random_number_generator</code>+ 的实例符合 RandomNumberGenerator 概念(std:25.2.11 [lib.alg.random.shuffle])。每调用一次,它返回区间
+ [0..<code>n</code>) 中的一个均匀分布的整数。</p> + + <p>模板参数 <code>IntType</code> 应指定某个类似于整数的值类型。</p> ++ <p><em>注:</em>我认为,C++标准将名字 RandomNumberGenerator 用于别的东西 是不幸的。</p>
+ + <h3>成员函数</h3> + <pre>random_number_generator(base_type & rng)<br></pre> - <p>These decorator class templates allow adaptation of the random number- generators and distribution functions to concepts found in the C++ Standard
- Library, in particular the RandomNumberGenerator and the InputIterator - concepts. The latter adaptation is useful, because the the basic random - number generators do not implement the InputIterator requirements per se, - in contrast to the distribution functions.</p> - - <h2><a name="synopsis" id="synopsis">Synopsis</a> of miscellaneous - decorators in header <code><boost/random.hpp></code></h2> - <pre> -namespace boost { - template<class UniformRandomNumberGenerator, class IntType = long> - class random_number_generator; -} // namespace boost -</pre> - - <h2><a name="random_number_generator" id="random_number_generator">Class - template <code>random_number_generator</code></a></h2> - - <h3>Synopsis</h3> - <pre> -template<class UniformRandomNumberGenerator, class IntType = long> -class random_number_generator -{ -public: - typedef UniformRandomNumberGenerator base_type; - typedef IntType argument_type; - typedef IntType result_type; - random_number_generator(base_type & rng); - result_type operator()(argument_type n); -}; -</pre> - - <h3>Description</h3> - - <p>Instantiations of class template <code>random_number_generator</code> - model a RandomNumberGenerator (std:25.2.11 [lib.alg.random.shuffle]). On - each invocation, it returns a uniformly distributed integer in the range - [0..<code>n</code>).</p> - - <p>The template parameter <code>IntType</code> shall denote some - integer-like value type.</p> -- <p><em>Note:</em> I consider it unfortunate that the C++ Standard uses the
- name RandomNumberGenerator for something rather specific.</p> - - <h3>Members</h3> - <pre> -random_number_generator(base_type & rng) -</pre> - - <p><strong>Effects:</strong> Constructs a- <code>random_number_generator</code> functor with the given uniform random
- number generator as the underlying source of random numbers.</p> - <pre> -result_type operator()(argument_type n) -</pre>+ <p><strong>作用:</strong>以给定的均匀随机数生成器作为底层的随机数源,构 造一个
+ <code>random_number_generator</code> 仿函数。</p> + <pre>result_type operator()(argument_type n)<br></pre> - <p><strong>Returns:</strong> The value of - <code>uniform_int<base_type>(rng, 0, n-1)()</code>.</p>+ <p><strong>返回:</strong><code>uniform_int<base_type>(rng, 0, n-1)()</code> 的值。</p>
<hr>- <p><a href="http://validator.w3.org/check?uri=referer";><img border="0" src= - "http://www.w3.org/Icons/valid-html401"; alt="Valid HTML 4.01 Transitional"
- height="31" width="88"></a></p>+ <p><a href="http://validator.w3.org/check?uri=referer";><img src="http://www.w3.org/Icons/valid-html401"; alt="Valid HTML 4.01 Transitional" border="0" height="31" width="88"></a></p>
<p>Revised<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
- <p><i>Copyright © 2000-2005 <a href= - "http://www.boost.org/people/jens_maurer.htm";>Jens Maurer</a></i></p>+ <p><i>Copyright (c) 2000-2005 <a href="http://www.boost.org/people/jens_maurer.htm";>Jens Maurer</a></i></p>
<p><i>Distributed under the Boost Software License, Version 1.0. (See 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> -</body> -</html>+ copy at <a href="http://www.boost.org/LICENSE_1_0.txt";>http://www.boost.org/LICENSE_1_0.txt</a>)</i></p>
+</body></html> \ No newline at end of file Modified: trunk/libs/random/random-variate.html ============================================================================== --- trunk/libs/random/random-variate.html (original) +++ trunk/libs/random/random-variate.html Fri Feb 13 06:52:56 2009 @@ -1,13 +1,11 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> - -<html> -<head> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <title>Boost 随机数库:变种生成器</title> -</head> + <title>Boost 随机数库:变种生成器</title></head> + -<body bgcolor="#FFFFFF" text="#000000"> +<body bgcolor="#ffffff" text="#000000"> <h1>Boost 随机数库:变种生成器</h1><p>变种生成器用来组合随机数生成器和随机分布。Boost.Random 提供了大量的 <a href="random-generators.html">生成器</a> 和 <a href="random-distributions.html">分布</a>。</p>
@@ -15,132 +13,74 @@<h2><a name="variate_generator" id="variate_generator"><code>variate_generator</code> 类模板</a></h2>
<h3>概览</h3> - <pre> -#include <<a href= -"../../boost/random/variate_generator.hpp">boost/random/variate_generator.hpp</a>> - -template<class Engine, class Distribution> -class variate_generator -{ -public: - typedef Engine engine_type; - typedef Distribution distribution_type; - typedef typename Distribution::result_type result_type; - - variate_generator(Engine e, Distribution d); - - result_type operator()(); - template<class T> - result_type operator()(T value); - - engine_value_type& engine(); - const engine_value_type& engine() const; - - result_type min() const; - result_type max() const; -}; -</pre>+ <pre>#include <<a href="../../boost/random/variate_generator.hpp">boost/random/variate_generator.hpp</a>><br><br>template<class Engine, class Distribution><br>class variate_generator<br>{<br>public:<br> typedef Engine engine_type;<br> typedef Distribution distribution_type;<br> typedef typename Distribution::result_type result_type;<br><br> variate_generator(Engine e, Distribution d);<br><br> result_type operator()();<br> template<class T><br> result_type operator()(T value);<br> <br> engine_value_type& engine();<br> const engine_value_type& engine() const;<br><br> result_type min() const;<br> result_type max() const;<br>};<br></pre>
<h3>描述</h3><p><code>variate_generator</code> 类模板的实例是 <a href="random-concepts.html#number_generator">数字生成器</a> 的模型。</p>
- <p>模板参数 <code>Engine</code> 的实参应当具有形式 U, U& 或 U*,其中 U 为 一均匀随机数生成器。成员 <code>engine_value_type</code> 则为 U (不是其指针或 引用类型)。</p> + <p>模板参数 <code>Engine</code> 的实参应当具有形式 U, U& 或 U*,其中 U 为一均匀随机数生成器。成员 <code>engine_value_type</code> 则为 U (不是其指 针或引用类型)。</p>
- <p><code>variate_generator</code> 的专门化满足 CopyConstructible 的需 求,也满足 Assignable 的需求,除非参数 Engine 为 U& 的形式。</p> + <p><code>variate_generator</code> 的专门化满足 CopyConstructible 的需 求,也满足 Assignable 的需求,除非参数 Engine 为 U& 的形式。</p>
<p>本节给出的所有函数的复杂度都是常数的。除构造函数外,均不抛出异常。</p> - <pre> - variate_generator(engine_type eng, distribution_type d) -</pre>+ <pre> variate_generator(engine_type eng, distribution_type d)<br></pre>
<p><strong>效果:</strong>用均匀随机数生成器 <code>eng</code> 和随机分布 <code>d</code> 构造一 <code>variate_generator</code> 对象。<br> <strong>抛出:</strong>Engine 或 Distribution 的复制构造函数所抛出的异 常。</p>
- <pre> - result_type operator()() -</pre> + <pre> result_type operator()()<br></pre> <p><strong>返回:</strong> <code>distribution()(e)</code><br> - <strong>Notes:</strong> The sequence of numbers produced by the uniform- random number generator <code>e</code>, s<sub>e</sub>, is obtained from the
- sequence of numbers produced by the associated uniform random number - generator <code>eng</code>, s<sub>eng</sub>, as follows: Consider the - values of <code>numeric_limits<<em>T</em>>::is_integer</code> for - <code><em>T</em></code> both <code>Distribution::input_type</code> and - <code>engine_value_type::result_type</code>. If the values for both types- are <code>true</code>, then s<sub>e</sub> is identical to s<sub>eng</sub>.
- Otherwise, if the values for both types are <code>false</code>, then the - numbers in s<sub>eng</sub> are divided by - <code>engine().max()-engine().min()</code> to obtain the numbers in - s<sub>e</sub>. Otherwise, if the value for - <code>engine_value_type::result_type</code> is <code>true</code> and the- value for <code>Distribution::input_type</code> is <code>false</code>, then
- the numbers in s<sub>eng</sub> are divided by - <code>engine().max()-engine().min()+1</code> to obtain the numbers in- s<sub>e</sub>. Otherwise, the mapping from s<sub>eng</sub> to s<sub>e</sub>
- is implementation-defined. In all cases, an implicit conversion from - <code>engine_value_type::result_type</code> to - <code>Distribution::input_type</code> is performed. If such a conversion - does not exist, the program is ill-formed.</p> - <pre> - template<class T> result_type operator()(T value) -</pre>+ <strong>Notes:</strong> 均匀随机数生成器 <code>e</code> 所生成的数字 序列 s<sub>e</sub>,是来自由相关联的均匀随机数生成器 <code>eng</code> 所生成 的数字序列 s<sub>eng</sub>,方法如下:考虑 <code>numeric_limits<<em>T</em>>::is_integer</code> 的值,其中
+ <code><em>T</em></code> 分别为 <code>Distribution::input_type</code> 和+ <code>engine_value_type::result_type</code>。如果对于此两种类型,该值都 为 <code>true</code>,则 s<sub>e</sub> 与 s<sub>eng</sub> 相同。否则,如果对 于此两种类型,该值均为 <code>false</code>,则 s<sub>eng</sub> 中的数字被用
+ <code>engine().max()-engine().min()</code> 相除,得到 + s<sub>e</sub> 中的数字。否则,如果对于+ <code>engine_value_type::result_type</code> 该值为 <code>true</code> 而对 于 <code>Distribution::input_type</code> 该值为 <code>false</code>,则 s<sub>eng</sub> 中的数字被用 <code>engine().max()-engine().min()+1</code> 相 除,得到
+ s<sub>e</sub> 中的数字。否则,从 s<sub>eng</sub> 到 s<sub>e</sub> + 的映射是由实现定义的。在所有情况下,都会执行一个由 + <code>engine_value_type::result_type</code> 到+ <code>Distribution::input_type</code> 的隐式转换。如果此转换不存在,则程 序是不正确的。</p> + <pre> template<class T> result_type operator()(T value)<br></pre>
<p><strong>返回:</strong> <code>distribution()(e, value)</code>。 <code>e</code> 的语义已在 <code>operator()()</code> 的描述中给出。</p>
- <pre> - engine_value_type& engine() -</pre> + <pre> engine_value_type& engine()<br></pre> <p><strong>返回:</strong>相关均匀随机数生成器的引用。</p> - <pre> - const engine_value_type& engine() const -</pre> + <pre> const engine_value_type& engine() const<br></pre> <p><strong>返回:</strong>相关均匀随机数生成器的引用。</p> - <pre> - distribution_type& distribution() -</pre> + <pre> distribution_type& distribution()<br></pre> <p><strong>返回:</strong>相关分布的引用。</p> - <pre> - const distribution_type& distribution() const -</pre> + <pre> const distribution_type& distribution() const<br></pre> <p><strong>返回:</strong>相关分布的引用。</p> - <pre> - result_type min() const -</pre> + <pre> result_type min() const<br></pre> <p><strong>前条件:</strong> <code>distribution().min()</code>有定义<br> <strong>返回:</strong> <code>distribution().min()</code></p> - <pre> - result_type max() const -</pre> + <pre> result_type max() const<br></pre> <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= - "http://www.w3.org/Icons/valid-html401"; alt="Valid HTML 4.01 Transitional"
- height="31" width="88"></a></p>+ <p><a href="http://validator.w3.org/check?uri=referer";><img src="http://www.w3.org/Icons/valid-html401"; alt="Valid HTML 4.01 Transitional" border="0" height="31" width="88"></a></p>
<p>Revised<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->05 December, 2006<!--webbot bot="Timestamp" endspan i-checksum="38516" --></p>
- <p><i>Copyright © 2003-2004 <a href= - "http://www.boost.org/people/jens_maurer.htm";>Jens Maurer</a></i></p>+ <p><i>Copyright (c) 2003-2004 <a href="http://www.boost.org/people/jens_maurer.htm";>Jens Maurer</a></i></p>
<p><i>Distributed under the Boost Software License, Version 1.0. (See 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>+ 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>Copyright (c) 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> +</body></html> \ No newline at end of file