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