Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/random/random-variate.html @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 5.0 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5
6<title>Boost Random Number Library Variate Generator</title>
7</head>
8
9<body bgcolor="#FFFFFF" text="#000000">
10
11<h1>Boost Random Number Library Variate Generator</h1>
12
13A random variate generator is used to join a random number generator
14together with a random number distribution.
15Boost.Random provides a vast choice of
16<a href="random-generators.html">generators</a>
17as well as
18<a href="random-distributions.html">distributions</a>
19.
20
21
22<h2><a name="variate_generator">Class template <code>variate_generator</code></h2>
23
24<h3>Synopsis</h3>
25<pre>
26#include &lt;<a href="../../boost/random/variate_generator.hpp">boost/random/variate_generator.hpp</a>&gt;
27
28template&lt;class Engine, class Distribution&gt;
29class variate_generator
30{
31public:
32  typedef Engine engine_type;
33  typedef Distribution distribution_type;
34  typedef typename Distribution::result_type result_type;
35
36  variate_generator(Engine e, Distribution d);
37
38  result_type operator()();
39  template&lt;class T&gt;
40  result_type operator()(T value);
41 
42  engine_value_type&amp; engine();
43  const engine_value_type&amp; engine() const;
44
45  result_type min() const;
46  result_type max() const;
47};
48</pre>
49
50<h3>Description</h3>
51
52Instantations of class template <code>variate_generator</code> model a
53<a href="random-concepts.html#number_generator">number generator</a>.
54<p>
55The argument for the template parameter <code>Engine</code> shall be
56of the form U, U&, or U*, where U models a uniform random number
57generator.  Then, the member <code>engine_value_type</code> names U
58(not the pointer or reference to U).
59<p>
60
61Specializations of <code>variate_generator</code> satisfy the
62requirements of CopyConstructible. They also satisfy the requirements
63of Assignable unless the template parameter Engine is of the form U&amp;.
64<p>
65
66The complexity of all functions specified in this section is
67constant. No function described in this section except the constructor
68throws an exception.
69
70<pre>    variate_generator(engine_type eng, distribution_type d)</pre>
71<strong>Effects:</strong> Constructs a <code>variate_generator</code>
72object with the associated uniform random number generator
73<code>eng</code> and the associated random distribution
74<code>d</code>.
75<br>
76<strong>Throws:</strong> If and what the copy constructor of Engine or
77Distribution throws.
78
79<pre>    result_type operator()()</pre>
80<strong>Returns:</strong> <code>distribution()(e)</code>
81<br>
82<strong>Notes:</strong> The sequence of numbers produced by the
83uniform random number generator <code>e</code>, s<sub>e</sub>, is
84obtained from the sequence of numbers produced by the associated
85uniform random number generator <code>eng</code>, s<sub>eng</sub>, as
86follows: Consider the values of
87<code>numeric_limits&lt;<em>T</em>&gt;::is_integer</code> for
88<code><em>T</em></code> both <code>Distribution::input_type</code> and
89<code>engine_value_type::result_type</code>.  If the values for both
90types are <code>true</code>, then s<sub>e</sub> is identical to
91s<sub>eng</sub>.  Otherwise, if the values for both types are
92<code>false</code>, then the numbers in s<sub>eng</sub> are divided by
93<code>engine().max()-engine().min()</code> to obtain the
94numbers in s<sub>e</sub>.  Otherwise, if the value for
95<code>engine_value_type::result_type</code> is <code>true</code> and
96the value for <code>Distribution::input_type</code> is
97<code>false</code>, then the numbers in s<sub>eng</sub> are divided by
98<code>engine().max()-engine().min()+1</code> to obtain the
99numbers in s<sub>e</sub>.  Otherwise, the mapping from s<sub>eng</sub>
100to s<sub>e</sub> is implementation-defined.  In all cases, an implicit
101conversion from <code>engine_value_type::result_type</code> to
102<code>Distribution::input_type</code> is performed.  If such a
103conversion does not exist, the program is ill-formed.
104
105<pre>    template&lt;class T> result_type operator()(T value)</pre>
106<strong>Returns:</strong> <code>distribution()(e, value)</code>.  For
107the semantics of <code>e</code>, see the description of
108<code>operator()()</code>.
109
110<pre>    engine_value_type& engine()</pre>
111<strong>Returns:</strong> A reference to the associated uniform random
112number generator.
113
114<pre>    const engine_value_type& engine() const</pre>
115<strong>Returns:</strong> A reference to the associated uniform random
116number generator.
117
118<pre>    distribution_type& distribution()</pre>
119<strong>Returns:</strong> A reference to the associated random
120distribution.
121
122<pre>    const distribution_type& distribution() const</pre>
123<strong>Returns:</strong> A reference to the associated random
124distribution.
125
126<pre>    result_type min() const</pre>
127<strong>Precondition:</strong> <code>distribution().min()</code> is
128well-formed
129<br>
130<strong>Returns:</strong> <code>distribution().min()</code>
131
132<pre>    result_type max() const</pre>
133<strong>Precondition:</strong> <code>distribution().max()</code> is
134well-formed
135<br>
136<strong>Returns:</strong> <code>distribution().max()</code>
137
138<p>
139<hr>
140<a href="../../people/jens_maurer.htm">Jens Maurer</a>,
1412003-10-25
142
143</body>
144</html>
Note: See TracBrowser for help on using the repository browser.