1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Boost Random Number Library Variate Generator</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h1>Boost Random Number Library Variate Generator</h1>
<p>A random variate generator is used to join a random number generator
together with a random number distribution. Boost.Random provides a vast
choice of <a href="random-generators.html">generators</a> as well as
<a href="random-distributions.html">distributions</a> .</p>
<h2><a name="variate_generator" id="variate_generator">Class template
<code>variate_generator</code></a></h2>
<h3>Synopsis</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>
<h3>Description</h3>
<p>Instantations of class template <code>variate_generator</code> model a
<a href="random-concepts.html#number_generator">number generator</a>.</p>
<p>The argument for the template parameter <code>Engine</code> shall be of
the form U, U&, or U*, where U models a uniform random number
generator. Then, the member <code>engine_value_type</code> names U (not the
pointer or reference to U).</p>
<p>Specializations of <code>variate_generator</code> satisfy the
requirements of CopyConstructible. They also satisfy the requirements of
Assignable unless the template parameter Engine is of the form U&.</p>
<p>The complexity of all functions specified in this section is constant.
No function described in this section except the constructor throws an
exception.</p>
<pre>
variate_generator(engine_type eng, distribution_type d)
</pre>
<p><strong>Effects:</strong> Constructs a <code>variate_generator</code>
object with the associated uniform random number generator <code>eng</code>
and the associated random distribution <code>d</code>.<br>
<strong>Throws:</strong> If and what the copy constructor of Engine or
Distribution throws.</p>
<pre>
result_type operator()()
</pre>
<p><strong>Returns:</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>
<p><strong>Returns:</strong> <code>distribution()(e, value)</code>. For the
semantics of <code>e</code>, see the description of
<code>operator()()</code>.</p>
<pre>
engine_value_type& engine()
</pre>
<p><strong>Returns:</strong> A reference to the associated uniform random
number generator.</p>
<pre>
const engine_value_type& engine() const
</pre>
<p><strong>Returns:</strong> A reference to the associated uniform random
number generator.</p>
<pre>
distribution_type& distribution()
</pre>
<p><strong>Returns:</strong> A reference to the associated random
distribution.</p>
<pre>
const distribution_type& distribution() const
</pre>
<p><strong>Returns:</strong> A reference to the associated random
distribution.</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>
<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>
<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>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>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>
|