boost-react-native-bundle
Version:
Boost library as in https://sourceforge.net/projects/boost/files/boost/1.57.0/
1,025 lines • 184 kB
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Reference</title>
<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../boost_random.html" title="Chapter 24. Boost.Random">
<link rel="prev" href="tutorial.html" title="Tutorial">
<link rel="next" href="../boost/random/additive_combine_engine.html" title="Class template additive_combine_engine">
</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="tutorial.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_random.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/additive_combine_engine.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_random.reference"></a><a class="link" href="reference.html" title="Reference">Reference</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="reference.html#boost_random.reference.concepts">Concepts</a></span></dt>
<dt><span class="section"><a href="reference.html#boost_random.reference.generators">Generators</a></span></dt>
<dt><span class="section"><a href="reference.html#boost_random.reference.distributions">Distributions</a></span></dt>
<dt><span class="section"><a href="reference.html#headers">Headers</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_random.reference.concepts"></a><a class="link" href="reference.html#boost_random.reference.concepts" title="Concepts">Concepts</a>
</h3></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="reference.html#boost_random.reference.concepts.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="reference.html#boost_random.reference.concepts.uniform_random_number_generator">Uniform
Random Number Generator</a></span></dt>
<dt><span class="section"><a href="reference.html#boost_random.reference.concepts.non_deterministic_uniform_random_number_generator">Non-deterministic
Uniform Random Number Generator</a></span></dt>
<dt><span class="section"><a href="reference.html#boost_random.reference.concepts.pseudo_random_number_generator">Pseudo-Random
Number Generator</a></span></dt>
<dt><span class="section"><a href="reference.html#boost_random.reference.concepts.seed_sequence">Seed
Sequence</a></span></dt>
<dt><span class="section"><a href="reference.html#boost_random.reference.concepts.random_distribution">Random
Distribution</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_random.reference.concepts.introduction"></a><a class="link" href="reference.html#boost_random.reference.concepts.introduction" title="Introduction">Introduction</a>
</h4></div></div></div>
<p>
Random numbers are required in a number of different problem domains, such
as
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
numerics (simulation, Monte-Carlo integration)
</li>
<li class="listitem">
games (non-deterministic enemy behavior)
</li>
<li class="listitem">
security (key generation)
</li>
<li class="listitem">
testing (random coverage in white-box tests)
</li>
</ul></div>
<p>
The Boost Random Number Generator Library provides a framework for random
number generators with well-defined properties so that the generators can
be used in the demanding numerics and security domains. For a general introduction
to random numbers in numerics, see
</p>
<div class="blockquote"><blockquote class="blockquote"><p>
"Numerical Recipes in C: The art of scientific computing",
William H. Press, Saul A. Teukolsky, William A. Vetterling, Brian P.
Flannery, 2nd ed., 1992, pp. 274-328
</p></blockquote></div>
<p>
Depending on the requirements of the problem domain, different variations
of random number generators are appropriate:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
non-deterministic random number generator
</li>
<li class="listitem">
pseudo-random number generator
</li>
<li class="listitem">
quasi-random number generator
</li>
</ul></div>
<p>
All variations have some properties in common, the concepts (in the STL
sense) is called <a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">UniformRandomNumberGenerator</a>.
This concept will be defined in a subsequent section.
</p>
<p>
The goals for this library are the following:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
allow easy integration of third-party random-number generators
</li>
<li class="listitem">
provide easy-to-use front-end classes which model popular distributions
</li>
<li class="listitem">
provide maximum efficiency
</li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_random.reference.concepts.uniform_random_number_generator"></a><a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">Uniform
Random Number Generator</a>
</h4></div></div></div>
<p>
A uniform random number generator provides a sequence of random numbers
uniformly distributed on a given range. The range can be compile-time fixed
or available (only) after run-time construction of the object.
</p>
<p>
The <span class="emphasis"><em>tight lower bound</em></span> of some (finite) set S is the
(unique) member l in S, so that for all v in S, l <= v holds. Likewise,
the <span class="emphasis"><em>tight upper bound</em></span> of some (finite) set S is the
(unique) member u in S, so that for all v in S, v <= u holds.
</p>
<p>
In the following table, X denotes a number generator class returning objects
of type T, and v is a const value of X.
</p>
<div class="table">
<a name="boost_random.reference.concepts.uniform_random_number_generator.uniformrandomnumbergenerator_requirements"></a><p class="title"><b>Table 24.1. UniformRandomNumberGenerator requirements</b></p>
<div class="table-contents"><table class="table" summary="UniformRandomNumberGenerator requirements">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
expression
</p>
</th>
<th>
<p>
return type
</p>
</th>
<th>
<p>
pre/post-condition
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span><span class="special">::</span><span class="identifier">result_type</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">is_specialized</span></code> is <code class="computeroutput"><span class="keyword">true</span></code>, <code class="computeroutput"><span class="identifier">T</span></code>
is <a href="../../../doc/html/LessThanComparable.html" target="_top">LessThanComparable</a>
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">u</span><span class="special">.</span><span class="keyword">operator</span><span class="special">()()</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
-
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">v</span><span class="special">.</span><span class="identifier">min</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
tight lower bound on the set of all values returned by <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>.
The return value of this function shall not change during the
lifetime of the object.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">v</span><span class="special">.</span><span class="identifier">max</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
if <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">is_integer</span></code>, tight upper bound
on the set of all values returned by <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>, otherwise, the smallest representable
number larger than the tight upper bound on the set of all values
returned by <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>. In any case, the return value
of this function shall not change during the lifetime of the
object.
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
The member functions <code class="computeroutput"><span class="identifier">min</span></code>,
<code class="computeroutput"><span class="identifier">max</span></code>, and <code class="computeroutput"><span class="keyword">operator</span><span class="special">()</span></code>
shall have amortized constant time complexity.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top">
<p>
For integer generators (i.e. integer <code class="computeroutput"><span class="identifier">T</span></code>),
the generated values <code class="computeroutput"><span class="identifier">x</span></code>
fulfill <code class="computeroutput"><span class="identifier">min</span><span class="special">()</span>
<span class="special"><=</span> <span class="identifier">x</span>
<span class="special"><=</span> <span class="identifier">max</span><span class="special">()</span></code>, for non-integer generators (i.e. non-integer
<code class="computeroutput"><span class="identifier">T</span></code>), the generated values
<code class="computeroutput"><span class="identifier">x</span></code> fulfill <code class="computeroutput"><span class="identifier">min</span><span class="special">()</span> <span class="special"><=</span> <span class="identifier">x</span> <span class="special"><</span> <span class="identifier">max</span><span class="special">()</span></code>.
</p>
<p>
Rationale: The range description with min and max serves two purposes.
First, it allows scaling of the values to some canonical range, such
as [0..1). Second, it describes the significant bits of the values, which
may be relevant for further processing.
</p>
<p>
The range is a closed interval [min,max] for integers, because the underlying
type may not be able to represent the half-open interval [min,max+1).
It is a half-open interval [min, max) for non-integers, because this
is much more practical for borderline cases of continuous distributions.
</p>
</td></tr>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top">
<p>
The <a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">UniformRandomNumberGenerator</a>
concept does not require <code class="computeroutput"><span class="keyword">operator</span><span class="special">()(</span><span class="keyword">long</span><span class="special">)</span></code> and thus it does not fulfill the <code class="computeroutput"><span class="identifier">RandomNumberGenerator</span></code> (std:25.2.11
[lib.alg.random.shuffle]) requirements. Use the <code class="computeroutput"><a class="link" href="../boost/random/random_number_generator.html" title="Class template random_number_generator">random_number_generator</a></code>
adapter for that.
</p>
<p>
Rationale: <code class="computeroutput"><span class="keyword">operator</span><span class="special">()(</span><span class="keyword">long</span><span class="special">)</span></code>
is not provided, because mapping the output of some generator with integer
range to a different integer range is not trivial.
</p>
</td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_random.reference.concepts.non_deterministic_uniform_random_number_generator"></a><a class="link" href="reference.html#boost_random.reference.concepts.non_deterministic_uniform_random_number_generator" title="Non-deterministic Uniform Random Number Generator">Non-deterministic
Uniform Random Number Generator</a>
</h4></div></div></div>
<p>
A non-deterministic uniform random number generator is a <a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">UniformRandomNumberGenerator</a>
that is based on some stochastic process. Thus, it provides a sequence
of truly-random numbers. Examples for such processes are nuclear decay,
noise of a Zehner diode, tunneling of quantum particles, rolling a die,
drawing from an urn, and tossing a coin. Depending on the environment,
inter-arrival times of network packets or keyboard events may be close
approximations of stochastic processes.
</p>
<p>
The class <code class="computeroutput"><a class="link" href="../boost/random/random_device.html" title="Class random_device">random_device</a></code>
is a model for a non-deterministic random number generator.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
This type of random-number generator is useful for security applications,
where it is important to prevent an outside attacker from guessing the
numbers and thus obtaining your encryption or authentication key. Thus,
models of this concept should be cautious not to leak any information,
to the extent possible by the environment. For example, it might be advisable
to explicitly clear any temporary storage as soon as it is no longer
needed.
</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_random.reference.concepts.pseudo_random_number_generator"></a><a class="link" href="reference.html#boost_random.reference.concepts.pseudo_random_number_generator" title="Pseudo-Random Number Generator">Pseudo-Random
Number Generator</a>
</h4></div></div></div>
<p>
A pseudo-random number generator is a <a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">UniformRandomNumberGenerator</a>
which provides a deterministic sequence of pseudo-random numbers, based
on some algorithm and internal state. <code class="computeroutput"><a class="link" href="../boost/random/linear_congruential_engine.html" title="Class template linear_congruential_engine">Linear
congruential</a></code> and <code class="computeroutput"><a class="link" href="../boost/random/inversive_con_idp198671104.html" title="Class template inversive_congruential_engine">inversive
congruential</a></code> generators are examples of such <a class="link" href="reference.html#boost_random.reference.concepts.pseudo_random_number_generator" title="Pseudo-Random Number Generator">pseudo-random
number generators</a>. Often, these generators are very sensitive to
their parameters. In order to prevent wrong implementations from being
used, an external testsuite should check that the generated sequence and
the validation value provided do indeed match.
</p>
<p>
Donald E. Knuth gives an extensive overview on pseudo-random number generation
in his book "The Art of Computer Programming, Vol. 2, 3rd edition,
Addison-Wesley, 1997". The descriptions for the specific generators
contain additional references.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
Because the state of a pseudo-random number generator is necessarily
finite, the sequence of numbers returned by the generator will loop eventually.
</p></td></tr>
</table></div>
<p>
In addition to the <a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">UniformRandomNumberGenerator</a>
requirements, a pseudo-random number generator has some additional requirements.
In the following table, <code class="computeroutput"><span class="identifier">X</span></code>
denotes a pseudo-random number generator class, <code class="computeroutput"><span class="identifier">u</span></code>
is a value of <code class="computeroutput"><span class="identifier">X</span></code>, <code class="computeroutput"><span class="identifier">i</span></code> is a value of integral type, <code class="computeroutput"><span class="identifier">s</span></code> is a value of a type which models
<a class="link" href="reference.html#boost_random.reference.concepts.seed_sequence" title="Seed Sequence">SeedSeq</a>,
and <code class="computeroutput"><span class="identifier">j</span></code> a value of type
<code class="computeroutput"><span class="keyword">unsigned</span> <span class="keyword">long</span>
<span class="keyword">long</span></code>.
</p>
<div class="table">
<a name="boost_random.reference.concepts.pseudo_random_number_generator.pseudorandomnumbergenerator_requirements"></a><p class="title"><b>Table 24.2. PseudoRandomNumberGenerator requirements</b></p>
<div class="table-contents"><table class="table" summary="PseudoRandomNumberGenerator requirements">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
expression
</p>
</th>
<th>
<p>
return type
</p>
</th>
<th>
<p>
pre/post-condition
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
-
</p>
</td>
<td>
<p>
creates a generator with a default seed.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
-
</p>
</td>
<td>
<p>
creates a generator seeding it with the integer <code class="computeroutput"><span class="identifier">i</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span><span class="special">(</span><span class="identifier">s</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
-
</p>
</td>
<td>
<p>
creates a generator setting its initial state from the <a class="link" href="reference.html#boost_random.reference.concepts.seed_sequence" title="Seed Sequence">SeedSeq</a>
<code class="computeroutput"><span class="identifier">s</span></code>.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">u</span><span class="special">.</span><span class="identifier">seed</span><span class="special">(...)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="keyword">void</span></code>
</p>
</td>
<td>
<p>
sets the current state to be identical to the state that would
be created by the corresponding constructor.
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">u</span><span class="special">.</span><span class="identifier">discard</span><span class="special">(</span><span class="identifier">j</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="keyword">void</span></code>
</p>
</td>
<td>
<p>
Advances the generator by <code class="computeroutput"><span class="identifier">j</span></code>
steps as if by <code class="computeroutput"><span class="identifier">j</span></code>
calls to <code class="computeroutput"><span class="identifier">u</span><span class="special">()</span></code>.
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
Classes which model a pseudo-random number generator shall also model
<a href="../../../doc/html/EqualityComparable.html" target="_top">EqualityComparable</a>,
i.e. implement <code class="computeroutput"><span class="keyword">operator</span><span class="special">==</span></code>.
Two pseudo-random number generators are defined to be <span class="emphasis"><em>equivalent</em></span>
if they both return an identical sequence of numbers starting from a given
state.
</p>
<p>
Classes which model a pseudo-random number generator shall also model the
Streamable concept, i.e. implement <code class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></code> and <code class="computeroutput"><span class="keyword">operator</span><span class="special">>></span></code>. <code class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></code> writes all current state of the
pseudo-random number generator to the given <code class="computeroutput"><span class="identifier">ostream</span></code>
so that <code class="computeroutput"><span class="keyword">operator</span><span class="special">>></span></code>
can restore the state at a later time. The state shall be written in a
platform-independent manner, but it is assumed that the <code class="computeroutput"><span class="identifier">locales</span></code>
used for writing and reading be the same. The pseudo-random number generator
with the restored state and the original at the just-written state shall
be equivalent.
</p>
<p>
Classes which model a pseudo-random number generator should also model
the <a href="../../../doc/html/CopyConstructible.html" target="_top">CopyConstructible</a>
and <a href="../../../doc/html/Assignable.html" target="_top">Assignable</a> concepts.
However, note that the sequences of the original and the copy are strongly
correlated (in fact, they are identical), which may make them unsuitable
for some problem domains. Thus, copying pseudo-random number generators
is discouraged; they should always be passed by (non-const) reference.
</p>
<p>
The classes <code class="computeroutput"><a class="link" href="../boost/random/rand48.html" title="Class rand48">rand48</a></code>,
<code class="computeroutput"><a class="link" href="../boost/random/minstd_rand.html" title="Type definition minstd_rand">minstd_rand</a></code>, and
<code class="computeroutput"><a class="link" href="../boost/random/mt19937.html" title="Type definition mt19937">mt19937</a></code> are models
for a pseudo-random number generator.
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
This type of random-number generator is useful for numerics, games and
testing. The non-zero arguments constructor(s) and the <code class="computeroutput"><span class="identifier">seed</span><span class="special">()</span></code>
member function(s) allow for a user-provided state to be installed in
the generator. This is useful for debugging Monte-Carlo algorithms and
analyzing particular test scenarios. The Streamable concept allows to
save/restore the state of the generator, for example to re-run a test
suite at a later time.
</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_random.reference.concepts.seed_sequence"></a><a class="link" href="reference.html#boost_random.reference.concepts.seed_sequence" title="Seed Sequence">Seed
Sequence</a>
</h4></div></div></div>
<p>
A SeedSeq represents a sequence of values that can be used to set the initial
state of a <a class="link" href="reference.html#boost_random.reference.concepts.pseudo_random_number_generator" title="Pseudo-Random Number Generator">PseudoRandomNumberGenerator</a>.
<code class="computeroutput"><span class="identifier">i</span></code> and <code class="computeroutput"><span class="identifier">j</span></code>
are RandomAccessIterators whose <code class="computeroutput"><span class="identifier">value_type</span></code>
is an unsigned integer type with at least 32 bits.
</p>
<div class="table">
<a name="boost_random.reference.concepts.seed_sequence.seedseq_requirements"></a><p class="title"><b>Table 24.3. SeedSeq requirements</b></p>
<div class="table-contents"><table class="table" summary="SeedSeq requirements">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
expression
</p>
</th>
<th>
<p>
return type
</p>
</th>
<th>
<p>
pre/post-condition
</p>
</th>
<th>
<p>
complexity
</p>
</th>
</tr></thead>
<tbody><tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">s</span><span class="special">.</span><span class="identifier">generate</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span>
<span class="identifier">j</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
void
</p>
</td>
<td>
<p>
stores 32-bit values to all the elements in the iterator range
defined by <code class="computeroutput"><span class="identifier">i</span></code>
and <code class="computeroutput"><span class="identifier">j</span></code>
</p>
</td>
<td>
<p>
O(j - i)
</p>
</td>
</tr></tbody>
</table></div>
</div>
<br class="table-break"><p>
The class <code class="computeroutput"><a class="link" href="../boost/random/seed_seq.html" title="Class seed_seq">seed_seq</a></code>
and every <a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">UniformRandomNumberGenerator</a>
provided by the library are models of <a class="link" href="reference.html#boost_random.reference.concepts.seed_sequence" title="Seed Sequence">SeedSeq</a>.
</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_random.reference.concepts.random_distribution"></a><a class="link" href="reference.html#boost_random.reference.concepts.random_distribution" title="Random Distribution">Random
Distribution</a>
</h4></div></div></div>
<p>
A random distribution produces random numbers distributed according to
some distribution, given uniformly distributed random values as input.
In the following table, <code class="computeroutput"><span class="identifier">X</span></code>
denotes a random distribution class returning objects of type <code class="computeroutput"><span class="identifier">T</span></code>, <code class="computeroutput"><span class="identifier">u</span></code>
is a value of <code class="computeroutput"><span class="identifier">X</span></code>, <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code>
are (possibly const) values of <code class="computeroutput"><span class="identifier">X</span></code>,
<code class="computeroutput"><span class="identifier">P</span></code> is the <code class="computeroutput"><span class="identifier">param_type</span></code> of the distribution, <code class="computeroutput"><span class="identifier">p</span></code> is a value of <code class="computeroutput"><span class="identifier">P</span></code>,
and <code class="computeroutput"><span class="identifier">e</span></code> is an lvalue of an
arbitrary type that meets the requirements of a <a class="link" href="reference.html#boost_random.reference.concepts.uniform_random_number_generator" title="Uniform Random Number Generator">UniformRandomNumberGenerator</a>,
returning values of type <code class="computeroutput"><span class="identifier">U</span></code>.
</p>
<div class="table">
<a name="boost_random.reference.concepts.random_distribution.random_distribution_requirements__in_addition_to_copyconstructible__and_assignable_"></a><p class="title"><b>Table 24.4. Random distribution requirements (in addition to CopyConstructible,
and Assignable)</b></p>
<div class="table-contents"><table class="table" summary="Random distribution requirements (in addition to CopyConstructible,
and Assignable)">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
expression
</p>
</th>
<th>
<p>
return type
</p>
</th>
<th>
<p>
pre/post-condition
</p>
</th>
<th>
<p>
complexity
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span><span class="special">::</span><span class="identifier">result_type</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
-
</p>
</td>
<td>
<p>
compile-time
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span><span class="special">::</span><span class="identifier">param_type</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">P</span></code>
</p>
</td>
<td>
<p>
A type that stores the parameters of the distribution, but not
any of the state used to generate random variates. <code class="computeroutput"><span class="identifier">param_type</span></code> provides the same
set of constructors and accessors as the distribution.
</p>
</td>
<td>
<p>
compile-time
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span><span class="special">(</span><span class="identifier">p</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">X</span></code>
</p>
</td>
<td>
<p>
Initializes a distribution from its parameters
</p>
</td>
<td>
<p>
O(size of state)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">u</span><span class="special">.</span><span class="identifier">reset</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="keyword">void</span></code>
</p>
</td>
<td>
<p>
subsequent uses of <code class="computeroutput"><span class="identifier">u</span></code>
do not depend on values produced by any engine prior to invoking
<code class="computeroutput"><span class="identifier">reset</span></code>.
</p>
</td>
<td>
<p>
constant
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">u</span><span class="special">(</span><span class="identifier">e</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
the sequence of numbers returned by successive invocations with
the same object <code class="computeroutput"><span class="identifier">e</span></code>
is randomly distributed with the probability density function
of the distribution
</p>
</td>
<td>
<p>
amortized constant number of invocations of <code class="computeroutput"><span class="identifier">e</span></code>
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">u</span><span class="special">(</span><span class="identifier">e</span><span class="special">,</span>
<span class="identifier">p</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
Equivalent to X(p)(e), but may use a different (and presumably
more efficient) implementation
</p>
</td>
<td>
<p>
amortized constant number of invocations of <code class="computeroutput"><span class="identifier">e</span></code>
+ O(size of state)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">param</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">P</span></code>
</p>
</td>
<td>
<p>
Returns the parameters of the distribution
</p>
</td>
<td>
<p>
O(size of state)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">param</span><span class="special">(</span><span class="identifier">p</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
void
</p>
</td>
<td>
<p>
Sets the parameters of the distribution
</p>
</td>
<td>
<p>
O(size of state)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">min</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
returns the minimum value of the distribution
</p>
</td>
<td>
<p>
constant
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">x</span><span class="special">.</span><span class="identifier">max</span><span class="special">()</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">T</span></code>
</p>
</td>
<td>
<p>
returns the maximum value of the distribution
</p>
</td>
<td>
<p>
constant
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">x</span> <span class="special">==</span>
<span class="identifier">y</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="keyword">bool</span></code>
</p>
</td>
<td>
<p>
Indicates whether the two distributions will produce identical
sequences of random variates if given equal generators
</p>
</td>
<td>
<p>
O(size of state)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">x</span> <span class="special">!=</span>
<span class="identifier">y</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="keyword">bool</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="special">!(</span><span class="identifier">x</span>
<span class="special">==</span> <span class="identifier">y</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
O(size of state)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">os</span> <span class="special"><<</span>
<span class="identifier">x</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span><span class="special">&</span></code>
</p>
</td>
<td>
<p>
writes a textual representation for the parameters and additional
internal data of the distribution <code class="computeroutput"><span class="identifier">x</span></code>
to <code class="computeroutput"><span class="identifier">os</span></code>. post:
The <code class="computeroutput"><span class="identifier">os</span><span class="special">.</span><span class="identifier">fmtflags</span></code> and fill character
are unchanged.
</p>
</td>
<td>
<p>
O(size of state)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">is</span> <span class="special">>></span>
<span class="identifier">u</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">istream</span><span class="special">&</span></code>
</p>
</td>
<td>
<p>
restores the parameters and additional internal data of the distribution
<code class="computeroutput"><span class="identifier">u</span></code>. pre: <code class="computeroutput"><span class="identifier">is</span></code> provides a textual representation
that was previously written by <code class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></code> post: The <code class="computeroutput"><span class="identifier">is</span><span class="special">.</span><span class="identifier">fmtflags</span></code> are unchanged.
</p>
</td>
<td>
<p>
O(size of state)
</p>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
Additional requirements: The sequence of numbers produced by repeated invocations
of <code class="computeroutput"><span class="identifier">x</span><span class="special">(</span><span class="identifier">e</span><span class="special">)</span></code> does
not change whether or not <code class="computeroutput"><span class="identifier">os</span>
<span class="special"><<</span> <span class="identifier">x</span></code>
is invoked between any of the invocations <code class="computeroutput"><span class="identifier">x</span><span class="special">(</span><span class="identifier">e</span><span class="special">)</span></code>.
If a textual representation is written using <code class="computeroutput"><span class="identifier">os</span>
<span class="special"><<</span> <span class="identifier">x</span></code>
and that representation is restored into the same or a different object
<code class="computeroutput"><span class="identifier">y</span></code> of the same type using
<code class="computeroutput"><span class="identifier">is</span> <span class="special">>></span>
<span class="identifier">y</span></code>, repeated invocations of <code class="computeroutput"><span class="identifier">y</span><span class="special">(</span><span class="identifier">e</span><span class="special">)</span></code> produce the same sequence of random numbers
as would repeated invocations of <code class="computeroutput"><span class="identifier">x</span><span class="special">(</span><span class="identifier">e</span><span class="special">)</span></code>.
</p>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_random.reference.generators"></a><a class="link" href="reference.html#boost_random.reference.generators" title="Generators">Generators</a>
</h3></div></div></div>
<p>
This library provides several <a class="link" href="reference.html#boost_random.reference.concepts.pseudo_random_number_generator" ti