107 lines
7.5 KiB
HTML
107 lines
7.5 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
<title>Chapter 34. Boost.Random</title>
|
||
<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
|
||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||
<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
|
||
<link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)">
|
||
<link rel="prev" href="proto/appendices.html" title="Appendices">
|
||
<link rel="next" href="boost_random/tutorial.html" title="Tutorial">
|
||
</head>
|
||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||
<table cellpadding="2" width="100%"><tr>
|
||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
|
||
<td align="center"><a href="../../index.html">Home</a></td>
|
||
<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
|
||
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
||
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
||
<td align="center"><a href="../../more/index.htm">More</a></td>
|
||
</tr></table>
|
||
<hr>
|
||
<div class="spirit-nav">
|
||
<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>
|
||
</div>
|
||
<div class="chapter">
|
||
<div class="titlepage"><div>
|
||
<div><h2 class="title">
|
||
<a name="boost_random"></a>Chapter 34. Boost.Random</h2></div>
|
||
<div><div class="author"><h3 class="author">
|
||
<span class="firstname">Jens</span> <span class="surname">Maurer</span>
|
||
</h3></div></div>
|
||
<div><p class="copyright">Copyright © 2000-2005 Jens Maurer</p></div>
|
||
<div><p class="copyright">Copyright © 2009, 2010 Steven Watanabe</p></div>
|
||
<div><div class="legalnotice">
|
||
<a name="boost_random.legal"></a><p>
|
||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||
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>)
|
||
</p>
|
||
</div></div>
|
||
</div></div>
|
||
<div class="toc">
|
||
<p><b>Table of Contents</b></p>
|
||
<dl class="toc">
|
||
<dt><span class="section"><a href="boost_random.html#boost_random.introduction">Introduction</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/tutorial.html">Tutorial</a></span></dt>
|
||
<dd><dl>
|
||
<dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_integers_in_a_range">Generating
|
||
integers in a range</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_integers_with_different_probabilities">Generating
|
||
integers with different probabilities</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_a_random_password">Generating
|
||
a random password</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/tutorial.html#boost_random.tutorial.generating_quasi_random_line_sphere_intersections">Generating
|
||
quasi-random line-sphere intersections</a></span></dt>
|
||
</dl></dd>
|
||
<dt><span class="section"><a href="boost_random/reference.html">Reference</a></span></dt>
|
||
<dd><dl>
|
||
<dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.concepts">Concepts</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.generators">Generators</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.distributions">Distributions</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/reference.html#boost_random.reference.utilities">Utilities</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/reference.html#headers">Headers</a></span></dt>
|
||
</dl></dd>
|
||
<dt><span class="section"><a href="boost_random/performance.html">Performance</a></span></dt>
|
||
<dt><span class="section"><a href="boost_random/history_and_acknowledgements.html">History and
|
||
Acknowledgements</a></span></dt>
|
||
</dl>
|
||
</div>
|
||
<div class="section">
|
||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||
<a name="boost_random.introduction"></a><a class="link" href="boost_random.html#boost_random.introduction" title="Introduction">Introduction</a>
|
||
</h2></div></div></div>
|
||
<p>
|
||
Random numbers are useful in a variety of applications. The Boost Random Number
|
||
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>
|
||
and <a class="link" href="boost_random/reference.html#boost_random.reference.distributions" title="Distributions">distributions</a>
|
||
to produce random numbers having useful properties, such as uniform distribution.
|
||
</p>
|
||
<p>
|
||
You should read the <a class="link" href="boost_random/reference.html#boost_random.reference.concepts" title="Concepts">concepts
|
||
documentation</a> for an introduction and the definition of the basic concepts.
|
||
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>.
|
||
</p>
|
||
<p>
|
||
For a very quick start, here's an example:
|
||
</p>
|
||
<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>
|
||
<span class="comment">// see pseudo-random number generators</span>
|
||
<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><> <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>
|
||
<span class="comment">// distribution that maps to 1..6</span>
|
||
<span class="comment">// see random number distributions</span>
|
||
<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>
|
||
</pre>
|
||
</div>
|
||
</div>
|
||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||
<td align="left"><p><small>Last revised: April 13, 2021 at 16:32:31 GMT</small></p></td>
|
||
<td align="right"><div class="copyright-footer"></div></td>
|
||
</tr></table>
|
||
<hr>
|
||
<div class="spirit-nav">
|
||
<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>
|
||
</div>
|
||
</body>
|
||
</html>
|