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</title> |
---|
7 | </head> |
---|
8 | |
---|
9 | <body bgcolor="#FFFFFF" text="#000000"> |
---|
10 | |
---|
11 | <table border="1" bgcolor="#007F7F" cellpadding="2"> |
---|
12 | <tr> |
---|
13 | <td bgcolor="#FFFFFF"><img src="../../boost.png" alt="boost.png (6897 bytes)" width="277" height="86"></td> |
---|
14 | <td><a href="../../index.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>Home</big></font></a></td> |
---|
15 | <td><a href="../libraries.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>Libraries</big></font></a></td> |
---|
16 | <td><a href="../../people/people.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>People</big></font></a></td> |
---|
17 | <td><a href="../../more/faq.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>FAQ</big></font></a></td> |
---|
18 | <td><a href="../../more/index.htm"><font face="Arial,Helvetica" color="#FFFFFF"><big>More</big></font></a></td> |
---|
19 | </tr> |
---|
20 | </table> |
---|
21 | |
---|
22 | <h1>Boost Random Number Library</h1> |
---|
23 | |
---|
24 | Random numbers are useful in a variety of applications. The Boost |
---|
25 | Random Number Library (Boost.Random for short) provides a vast variety |
---|
26 | of generators and distributions to produce random numbers having |
---|
27 | useful properties, such as uniform distribution. |
---|
28 | <p> |
---|
29 | You should read the |
---|
30 | <a href="random-concepts.html">concepts documentation</a> |
---|
31 | for an introduction and the definition of the basic concepts. For a |
---|
32 | quick start, it may be sufficient to have a look at <a |
---|
33 | href="random_demo.cpp">random_demo.cpp</a>. |
---|
34 | <p> |
---|
35 | For a very quick start, here's an example: |
---|
36 | <pre> |
---|
37 | boost::mt19937 rng; // produces randomness out of thin air |
---|
38 | // see pseudo-random number generators |
---|
39 | boost::uniform_int<> six(1,6) // distribution that maps to 1..6 |
---|
40 | // see random number distributions |
---|
41 | boost::variate_generator<boost::mt19937&, boost::uniform_int<> > |
---|
42 | die(rng, six); // glues randomness with mapping |
---|
43 | int x = die(); // simulate rolling a die |
---|
44 | </pre> |
---|
45 | |
---|
46 | <h2>Library Organization</h2> |
---|
47 | |
---|
48 | The library is separated into several header files, all within the |
---|
49 | <code>boost/random/</code> directory. Additionally, a convenience |
---|
50 | header file which includes all other headers in |
---|
51 | <code>boost/random/</code> is available as |
---|
52 | <code><a href="../../boost/random.hpp">boost/random.hpp</a></code>. |
---|
53 | <p> |
---|
54 | |
---|
55 | A front-end class template called <code>variate_generate</code> is |
---|
56 | provided; please read the |
---|
57 | <a href="random-variate.html">documentation</a> about it. |
---|
58 | <ul> |
---|
59 | <li><code><a href="../../boost/random/variate_generator.hpp">boost/random/variate_generator.hpp</a></code> |
---|
60 | </ul> |
---|
61 | |
---|
62 | Several random number generators are available in the following |
---|
63 | header files; please read the |
---|
64 | <a href="random-generators.html">documentation</a> about these. |
---|
65 | |
---|
66 | <ul> |
---|
67 | <li><code><a href="../../boost/random/linear_congruential.hpp">boost/random/linear_congruential.hpp</a></code> |
---|
68 | <li><code><a href="../../boost/random/additive_combine.hpp">boost/random/additive_combine.hpp</a></code> |
---|
69 | <li><code><a href="../../boost/random/inversive_congruential.hpp">boost/random/inversive_congruential.hpp</a></code> |
---|
70 | <li><code><a href="../../boost/random/shuffle_output.hpp">boost/random/shuffle_output.hpp</a></code> |
---|
71 | <li><code><a href="../../boost/random/mersenne_twister.hpp">boost/random/mersenne_twister.hpp</a></code> |
---|
72 | <li><code><a href="../../boost/random/lagged_fibonacci.hpp">boost/random/lagged_fibonacci.hpp</a></code> |
---|
73 | </ul> |
---|
74 | |
---|
75 | |
---|
76 | Similarly, several random number distributions are available in the |
---|
77 | following header files; please read the |
---|
78 | <a href="random-distributions.html">documentation</a> about these. |
---|
79 | |
---|
80 | <ul> |
---|
81 | <li><code><a href="../../boost/random/uniform_smallint.hpp">boost/random/uniform_smallint.hpp</a></code> |
---|
82 | <li><code><a href="../../boost/random/uniform_int.hpp">boost/random/uniform_int.hpp</a></code> |
---|
83 | <li><code><a href="../../boost/random/uniform_01.hpp">boost/random/uniform_01.hpp</a></code> |
---|
84 | <li><code><a href="../../boost/random/uniform_real.hpp">boost/random/uniform_real.hpp</a></code> |
---|
85 | <li><code><a href="../../boost/random/triangle_distribution.hpp">boost/random/triangle_distribution.hpp</a></code> |
---|
86 | <li><code><a href="../../boost/random/bernoulli_distribution.hpp">boost/random/bernoulli_distribution.hpp</a></code> |
---|
87 | <li><code><a href="../../boost/random/cauchy_distribution.hpp">boost/random/cauchy_distribution.hpp</a></code> |
---|
88 | <li><code><a href="../../boost/random/exponential_distribution.hpp">boost/random/exponential_distribution.hpp</a></code> |
---|
89 | <li><code><a href="../../boost/random/geometric_distribution.hpp">boost/random/geometric_distribution.hpp</a></code> |
---|
90 | <li><code><a href="../../boost/random/normal_distribution.hpp">boost/random/normal_distribution.hpp</a></code> |
---|
91 | <li><code><a href="../../boost/random/lognormal_distribution.hpp">boost/random/lognormal_distribution.hpp</a></code> |
---|
92 | <li><code><a href="../../boost/random/uniform_on_sphere.hpp">boost/random/uniform_on_sphere.hpp</a></code> |
---|
93 | </ul> |
---|
94 | |
---|
95 | Additionally, non-deterministic random number generators are available |
---|
96 | in the header |
---|
97 | <code><a href="../../boost/nondet_random.hpp"><boost/nondet_random.hpp></a></code>. |
---|
98 | <a href="nondet_random.html">Documentation</a> is also available. |
---|
99 | |
---|
100 | <p> |
---|
101 | |
---|
102 | In order to map the interface of the generators and distribution functions |
---|
103 | to other concepts, some <a href="random-misc.html">decorators</a> are available. |
---|
104 | |
---|
105 | <h2>Tests</h2> |
---|
106 | |
---|
107 | An extensive test suite for the pseudo-random number generators and |
---|
108 | distributions is available as |
---|
109 | <a href="random_test.cpp">random_test.cpp</a>. |
---|
110 | <p> |
---|
111 | Some <a href="random-performance.html">performance results</a> obtained |
---|
112 | using <a href="random_speed.cpp">random_speed.cpp</a> are also available. |
---|
113 | |
---|
114 | <h2>Rationale</h2> |
---|
115 | |
---|
116 | The methods for generating and evaluating deterministic and |
---|
117 | non-deterministic random numbers differ radically. Furthermore, due |
---|
118 | to the inherent deterministic design of present-day computers, it is |
---|
119 | often difficult to implement non-deterministic random number |
---|
120 | generation facilities. Thus, the random number library is split into |
---|
121 | separate header files, mirroring the two different application |
---|
122 | domains. |
---|
123 | |
---|
124 | |
---|
125 | <h2>History and Acknowledgements</h2> |
---|
126 | |
---|
127 | In November 1999, Jeet Sukumaran proposed a framework based on virtual |
---|
128 | functions, and later sketched a template-based approach. Ed Brey |
---|
129 | pointed out that Microsoft Visual C++ does not support in-class member |
---|
130 | initializations and suggested the <code>enum</code> workaround. Dave |
---|
131 | Abrahams highlighted quantization issues. |
---|
132 | <p> |
---|
133 | The first public release of this random number library materialized in |
---|
134 | March 2000 after extensive discussions on the boost mailing list. |
---|
135 | Many thanks to Beman Dawes for his original <code>min_rand</code> |
---|
136 | class, portability fixes, documentation suggestions, and general |
---|
137 | guidance. Harry Erwin sent a header file which provided additional |
---|
138 | insight into the requirements. Ed Brey and Beman Dawes wanted an |
---|
139 | iterator-like interface. |
---|
140 | <p> |
---|
141 | Beman Dawes managed the formal review, during which Matthias Troyer, |
---|
142 | Csaba Szepesvari, and Thomas Holenstein gave detailed comments. The |
---|
143 | reviewed version became an official part of boost on 17 June 2000. |
---|
144 | <p> |
---|
145 | Gary Powell contributed suggestions for code cleanliness. Dave |
---|
146 | Abrahams and Howard Hinnant suggested to move the basic generator |
---|
147 | templates from namespace <code>boost::detail</code> to |
---|
148 | <code>boost::random</code>. |
---|
149 | <p> |
---|
150 | Ed Brey asked to remove superfluous warnings and helped with |
---|
151 | <code>uint64_t</code> handling. Andreas Scherer tested with MSVC. |
---|
152 | Matthias Troyer contributed a lagged Fibonacci generator. Michael |
---|
153 | Stevens found a bug in the copy semantics of normal_distribution and |
---|
154 | suggested documentation improvements. |
---|
155 | <p> |
---|
156 | <hr> |
---|
157 | <a href="../../people/jens_maurer.htm">Jens Maurer</a>, |
---|
158 | 2001-08-31 |
---|
159 | |
---|
160 | </body> |
---|
161 | </html> |
---|