Imported Upstream version 1.72.0
[platform/upstream/boost.git] / doc / html / boost_random.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Chapter&#160;34.&#160;Boost.Random</title>
6 <link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="libraries.html" title="Part&#160;I.&#160;The Boost C++ Libraries (BoostBook Subset)">
10 <link rel="prev" href="proto/appendices.html" title="Appendices">
11 <link rel="next" href="boost_random/tutorial.html" title="Tutorial">
12 </head>
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
16 <td align="center"><a href="../../index.html">Home</a></td>
17 <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../more/index.htm">More</a></td>
21 </tr></table>
22 <hr>
23 <div class="spirit-nav">
24 <a accesskey="p" href="proto/appendices.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_random/tutorial.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
25 </div>
26 <div class="chapter">
27 <div class="titlepage"><div>
28 <div><h2 class="title">
29 <a name="boost_random"></a>Chapter&#160;34.&#160;Boost.Random</h2></div>
30 <div><div class="author"><h3 class="author">
31 <span class="firstname">Jens</span> <span class="surname">Maurer</span>
32 </h3></div></div>
33 <div><p class="copyright">Copyright &#169; 2000-2005 Jens Maurer</p></div>
34 <div><p class="copyright">Copyright &#169; 2009, 2010 Steven Watanabe</p></div>
35 <div><div class="legalnotice">
36 <a name="boost_random.legal"></a><p>
37         Distributed under the Boost Software License, Version 1.0. (See accompanying
38         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
39       </p>
40 </div></div>
41 </div></div>
42 <div class="toc">
43 <p><b>Table of Contents</b></p>
44 <dl class="toc">
45 <dt><span class="section"><a href="boost_random.html#boost_random.introduction">Introduction</a></span></dt>
46 <dt><span class="section"><a href="boost_random/tutorial.html">Tutorial</a></span></dt>
47 <dd><dl>
48 <dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_integers_in_a_range">Generating
49       integers in a range</a></span></dt>
50 <dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_integers_with_different_probabilities">Generating
51       integers with different probabilities</a></span></dt>
52 <dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_a_random_password">Generating
53       a random password</a></span></dt>
54 <dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_quasi_random_line_sphere_intersections">Generating
55       quasi-random line-sphere intersections</a></span></dt>
56 </dl></dd>
57 <dt><span class="section"><a href="boost_random/reference.html">Reference</a></span></dt>
58 <dd><dl>
59 <dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.concepts">Concepts</a></span></dt>
60 <dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.generators">Generators</a></span></dt>
61 <dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.distributions">Distributions</a></span></dt>
62 <dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.utilities">Utilities</a></span></dt>
63 <dt><span class="section"><a href="boost_random/reference.html#headers">Headers</a></span></dt>
64 </dl></dd>
65 <dt><span class="section"><a href="boost_random/performance.html">Performance</a></span></dt>
66 <dt><span class="section"><a href="boost_random/history_and_acknowledgements.html">History and
67     Acknowledgements</a></span></dt>
68 </dl>
69 </div>
70 <div class="section">
71 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
72 <a name="boost_random.introduction"></a><a class="link" href="boost_random.html#boost_random.introduction" title="Introduction">Introduction</a>
73 </h2></div></div></div>
74 <p>
75       Random numbers are useful in a variety of applications. The Boost Random Number
76       Library (Boost.Random for short) provides a variety of <a class="link" href="boost_random/reference.html#boost_random.reference.generators" title="Generators">generators</a>
77       and <a class="link" href="boost_random/reference.html#boost_random.reference.distributions" title="Distributions">distributions</a>
78       to produce random numbers having useful properties, such as uniform distribution.
79     </p>
80 <p>
81       You should read the <a class="link" href="boost_random/reference.html#boost_random.reference.concepts" title="Concepts">concepts
82       documentation</a> for an introduction and the definition of the basic concepts.
83       For a quick start, it may be sufficient to have a look at <a href="../../libs/random/example/random_demo.cpp" target="_top">random_demo.cpp</a>.
84     </p>
85 <p>
86       For a very quick start, here's an example:
87     </p>
88 <pre class="programlisting"><code class="computeroutput"><a class="link" href="boost/random/mt19937.html" title="Type definition mt19937">boost::random::mt19937</a></code> <span class="identifier">rng</span><span class="special">;</span>         <span class="comment">// produces randomness out of thin air</span>
89                                     <span class="comment">// see pseudo-random number generators</span>
90 <code class="computeroutput"><a class="link" href="boost/random/uniform_int_distribution.html" title="Class template uniform_int_distribution">boost::random::uniform_int_distribution</a></code>&lt;&gt; <span class="identifier">six</span><span class="special">(</span><span class="number">1</span><span class="special">,</span><span class="number">6</span><span class="special">);</span>
91                                     <span class="comment">// distribution that maps to 1..6</span>
92                                     <span class="comment">// see random number distributions</span>
93 <span class="keyword">int</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">six</span><span class="special">(</span><span class="identifier">rng</span><span class="special">);</span>                   <span class="comment">// simulate rolling a die</span>
94 </pre>
95 </div>
96 </div>
97 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
98 <td align="left"><p><small>Last revised: December 10, 2019 at 00:26:26 GMT</small></p></td>
99 <td align="right"><div class="copyright-footer"></div></td>
100 </tr></table>
101 <hr>
102 <div class="spirit-nav">
103 <a accesskey="p" href="proto/appendices.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost_random/tutorial.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
104 </div>
105 </body>
106 </html>