|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68822 - in trunk: boost/random libs/random/doc libs/random/example
From: steven_at_[hidden]
Date: 2011-02-12 22:29:04
Author: steven_watanabe
Date: 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
New Revision: 68822
URL: http://svn.boost.org/trac/boost/changeset/68822
Log:
Sync the docs with the current library.
Text files modified:
trunk/boost/random/additive_combine.hpp | 4 +
trunk/boost/random/bernoulli_distribution.hpp | 3 -
trunk/boost/random/binomial_distribution.hpp | 2
trunk/boost/random/cauchy_distribution.hpp | 3 -
trunk/boost/random/chi_squared_distribution.hpp | 2
trunk/boost/random/discard_block.hpp | 4 ++
trunk/boost/random/discrete_distribution.hpp | 4 +-
trunk/boost/random/exponential_distribution.hpp | 2 -
trunk/boost/random/geometric_distribution.hpp | 6 ++
trunk/boost/random/independent_bits.hpp | 10 +---
trunk/boost/random/inversive_congruential.hpp | 2
trunk/boost/random/lagged_fibonacci.hpp | 14 +++---
trunk/boost/random/linear_congruential.hpp | 6 +-
trunk/boost/random/linear_feedback_shift.hpp | 4 +-
trunk/boost/random/lognormal_distribution.hpp | 8 +++-
trunk/boost/random/mersenne_twister.hpp | 7 +--
trunk/boost/random/negative_binomial_distribution.hpp | 2
trunk/boost/random/normal_distribution.hpp | 5 --
trunk/boost/random/piecewise_constant_distribution.hpp | 11 -----
trunk/boost/random/piecewise_linear_distribution.hpp | 7 ---
trunk/boost/random/poisson_distribution.hpp | 2
trunk/boost/random/random_device.hpp | 2
trunk/boost/random/seed_seq.hpp | 18 +++++++++
trunk/boost/random/shuffle_order.hpp | 12 +++++-
trunk/boost/random/student_t_distribution.hpp | 2
trunk/boost/random/subtract_with_carry.hpp | 30 ++++++++++-----
trunk/boost/random/triangle_distribution.hpp | 2
trunk/boost/random/uniform_01.hpp | 5 ++
trunk/boost/random/uniform_smallint.hpp | 6 ++-
trunk/boost/random/variate_generator.hpp | 3 -
trunk/boost/random/xor_combine.hpp | 2
trunk/libs/random/doc/Jamfile.v2 | 41 +++++++++++++++-------
trunk/libs/random/doc/concepts.qbk | 67 ++++++++----------------------------
trunk/libs/random/doc/distributions.qbk | 55 +++++++++++++++++++++++------
trunk/libs/random/doc/random.qbk | 74 ++++++++++++++++++---------------------
trunk/libs/random/example/die.cpp | 26 ++++---------
trunk/libs/random/example/password.cpp | 12 ++---
trunk/libs/random/example/weighted_die.cpp | 31 +++++++---------
38 files changed, 253 insertions(+), 243 deletions(-)
Modified: trunk/boost/random/additive_combine.hpp
==============================================================================
--- trunk/boost/random/additive_combine.hpp (original)
+++ trunk/boost/random/additive_combine.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -247,7 +247,8 @@
const bool additive_combine_engine<MLCG1, MLCG2>::has_fixed_range;
#endif
-/// \cond
+/// \cond show_deprecated
+
/** Provided for backwards compatibility. */
template<class MLCG1, class MLCG2, typename MLCG1::result_type val = 0>
class additive_combine : public additive_combine_engine<MLCG1, MLCG2>
@@ -263,6 +264,7 @@
template<class It>
additive_combine(It& first, It last) : base_t(first, last) {}
};
+
/// \endcond
/**
Modified: trunk/boost/random/bernoulli_distribution.hpp
==============================================================================
--- trunk/boost/random/bernoulli_distribution.hpp (original)
+++ trunk/boost/random/bernoulli_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -185,10 +185,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(bernoulli_distribution)
private:
-
- /// \cond
RealType _p;
- /// \endcond
};
} // namespace random
Modified: trunk/boost/random/binomial_distribution.hpp
==============================================================================
--- trunk/boost/random/binomial_distribution.hpp (original)
+++ trunk/boost/random/binomial_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -236,7 +236,7 @@
private:
- /// @cond
+ /// @cond show_private
template<class CharT, class Traits>
void read(std::basic_istream<CharT, Traits>& is) {
Modified: trunk/boost/random/cauchy_distribution.hpp
==============================================================================
--- trunk/boost/random/cauchy_distribution.hpp (original)
+++ trunk/boost/random/cauchy_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -201,11 +201,8 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(cauchy_distribution)
private:
-
- /// \cond
RealType _median;
RealType _sigma;
- /// \endcond
};
} // namespace random
Modified: trunk/boost/random/chi_squared_distribution.hpp
==============================================================================
--- trunk/boost/random/chi_squared_distribution.hpp (original)
+++ trunk/boost/random/chi_squared_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -187,7 +187,7 @@
private:
- /// @cond
+ /// @cond show_private
template<class CharT, class Traits>
void read(std::basic_istream<CharT, Traits>& is) {
Modified: trunk/boost/random/discard_block.hpp
==============================================================================
--- trunk/boost/random/discard_block.hpp (original)
+++ trunk/boost/random/discard_block.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -202,6 +202,8 @@
const std::size_t discard_block_engine<URNG, p, r>::used_block;
#endif
+/// \cond \show_deprecated
+
template<class URNG, int p, int r>
class discard_block : public discard_block_engine<URNG, p, r>
{
@@ -221,6 +223,8 @@
{ return (this->base().max)(); }
};
+/// \endcond
+
} // namespace random
} // namespace boost
Modified: trunk/boost/random/discrete_distribution.hpp
==============================================================================
--- trunk/boost/random/discrete_distribution.hpp (original)
+++ trunk/boost/random/discrete_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -146,7 +146,7 @@
/** Returns true if the two sets of parameters are different. */
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
private:
- /// @cond
+ /// @cond show_private
friend class discrete_distribution;
explicit param_type(const discrete_distribution& dist)
: _probabilities(dist.probabilities())
@@ -374,7 +374,7 @@
private:
- /// @cond
+ /// @cond show_private
template<class Iter>
void init(Iter first, Iter last, std::input_iterator_tag)
Modified: trunk/boost/random/exponential_distribution.hpp
==============================================================================
--- trunk/boost/random/exponential_distribution.hpp (original)
+++ trunk/boost/random/exponential_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -170,9 +170,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(exponential_distribution)
private:
- /// \cond
result_type _lambda;
- /// \endcond
};
} // namespace random
Modified: trunk/boost/random/geometric_distribution.hpp
==============================================================================
--- trunk/boost/random/geometric_distribution.hpp (original)
+++ trunk/boost/random/geometric_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -199,7 +199,7 @@
private:
- /// \cond
+ /// \cond show_private
void init()
{
@@ -215,6 +215,8 @@
} // namespace random
+/// \cond show_deprecated
+
/**
* Provided for backwards compatibility. This class is
* deprecated. It provides the old behavior of geometric_distribution
@@ -258,6 +260,8 @@
impl_type _impl;
};
+/// \endcond
+
} // namespace boost
#endif // BOOST_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
Modified: trunk/boost/random/independent_bits.hpp
==============================================================================
--- trunk/boost/random/independent_bits.hpp (original)
+++ trunk/boost/random/independent_bits.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -84,14 +84,10 @@
// Required by old Boost.Random concept
BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
- /**
- * Returns the smallest value that the generator can produce
- */
+ /** Returns the smallest value that the generator can produce. */
static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ return 0; }
- /**
- * Returns the largest value that the generator can produce
- */
+ /** Returns the largest value that the generator can produce. */
static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{ return boost::low_bits_mask_t<w>::sig_bits; }
@@ -265,7 +261,7 @@
private:
- /// \cond
+ /// \cond show_private
typedef typename base_type::result_type base_result;
typedef typename make_unsigned<base_result>::type base_unsigned;
Modified: trunk/boost/random/inversive_congruential.hpp
==============================================================================
--- trunk/boost/random/inversive_congruential.hpp (original)
+++ trunk/boost/random/inversive_congruential.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -235,7 +235,7 @@
const typename inversive_congruential_engine<IntType, a, b, p>::result_type inversive_congruential_engine<IntType, a, b, p>::default_seed;
#endif
-/// \cond
+/// \cond show_deprecated
// provided for backwards compatibility
template<class IntType, IntType a, IntType b, IntType p, IntType val = 0>
Modified: trunk/boost/random/lagged_fibonacci.hpp
==============================================================================
--- trunk/boost/random/lagged_fibonacci.hpp (original)
+++ trunk/boost/random/lagged_fibonacci.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -35,7 +35,7 @@
namespace random {
/**
- * Instantiations of class template \lagged_fibonacci model a
+ * Instantiations of class template \lagged_fibonacci_engine model a
* \pseudo_random_number_generator. It uses a lagged Fibonacci
* algorithm with two lags @c p and @c q:
* x(i) = x(i-p) + x(i-q) (mod 2<sup>w</sup>) with p > q.
@@ -184,7 +184,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(lagged_fibonacci_engine)
private:
- /// \cond hide_private_members
+ /// \cond show_private
void fill();
/// \endcond
@@ -202,7 +202,7 @@
const unsigned int lagged_fibonacci_engine<UIntType, w, p, q>::short_lag;
#endif
-/// \cond
+/// \cond show_private
template<class UIntType, int w, unsigned int p, unsigned int q>
void lagged_fibonacci_engine<UIntType, w, p, q>::fill()
@@ -219,7 +219,7 @@
/// \endcond
-/// \cond
+/// \cond show_deprecated
// provided for backwards compatibility
template<class UIntType, int w, unsigned int p, unsigned int q, UIntType v = 0>
@@ -432,7 +432,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(lagged_fibonacci_01_engine)
private:
- /// \cond
+ /// \cond show_private
void fill();
static RealType modulus()
{
@@ -457,7 +457,7 @@
#endif
-/// \cond
+/// \cond show_private
template<class RealType, int w, unsigned int p, unsigned int q>
void lagged_fibonacci_01_engine<RealType, w, p, q>::fill()
{
@@ -480,7 +480,7 @@
}
/// \endcond
-/// \cond
+/// \cond show_deprecated
// provided for backwards compatibility
template<class RealType, int w, unsigned int p, unsigned int q>
Modified: trunk/boost/random/linear_congruential.hpp
==============================================================================
--- trunk/boost/random/linear_congruential.hpp (original)
+++ trunk/boost/random/linear_congruential.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -234,7 +234,7 @@
private:
- /// \cond
+ /// \cond show_private
template<class CharT, class Traits>
void read(std::basic_istream<CharT, Traits>& is) {
@@ -267,7 +267,7 @@
const IntType linear_congruential_engine<IntType,a,c,m>::default_seed;
#endif
-/// \cond
+/// \cond show_deprecated
// provided for backwards compatibility
template<class IntType, IntType a, IntType c, IntType m, IntType val = 0>
@@ -421,7 +421,7 @@
friend bool operator!=(const rand48& x, const rand48& y)
{ return !(x == y); }
private:
- /// \cond
+ /// \cond show_private
typedef random::linear_congruential_engine<uint64_t,
// xxxxULL is not portable
uint64_t(0xDEECE66DUL) | (uint64_t(0x5) << 32),
Modified: trunk/boost/random/linear_feedback_shift.hpp
==============================================================================
--- trunk/boost/random/linear_feedback_shift.hpp (original)
+++ trunk/boost/random/linear_feedback_shift.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -170,7 +170,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(linear_feedback_shift_engine)
private:
- /// \cond
+ /// \cond show_private
static UIntType wordmask() { return boost::low_bits_mask_t<w>::sig_bits; }
/// \endcond
UIntType value;
@@ -192,7 +192,7 @@
const UIntType linear_feedback_shift_engine<UIntType, w, k, q, s>::default_seed;
#endif
-/// \cond
+/// \cond show_deprecated
/** Provided for backwards compatibility. */
template<class UIntType, int w, int k, int q, int s, UIntType v = 0>
Modified: trunk/boost/random/lognormal_distribution.hpp
==============================================================================
--- trunk/boost/random/lognormal_distribution.hpp (original)
+++ trunk/boost/random/lognormal_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -188,12 +188,14 @@
} // namespace random
+/// \cond show_deprecated
+
/**
* Provided for backwards compatibility. This class is
* deprecated. It provides the old behavior of lognormal_distribution with
* \f$\displaystyle p(x) = \frac{1}{x \sigma_N \sqrt{2\pi}} e^{\frac{-\left(\log(x)-\mu_N\right)^2}{2\sigma_N^2}}\f$
* for x > 0, where \f$\displaystyle \mu_N = \log\left(\frac{\mu^2}{\sqrt{\sigma^2 + \mu^2}}\right)\f$ and
- * \f$\displaystyle \sigma_N = \sqrt{\log\left(1 + \frac{\sigma^2}{\mu^2}\right)}.
+ * \f$\displaystyle \sigma_N = \sqrt{\log\left(1 + \frac{\sigma^2}{\mu^2}\right)}\f$.
*/
template<class RealType = double>
class lognormal_distribution
@@ -229,7 +231,7 @@
return is;
}
private:
- /// \cond
+ /// \cond show_private
void init()
{
using std::log;
@@ -245,6 +247,8 @@
/// \endcond
};
+/// \endcond
+
} // namespace boost
#endif // BOOST_RANDOM_LOGNORMAL_DISTRIBUTION_HPP
Modified: trunk/boost/random/mersenne_twister.hpp
==============================================================================
--- trunk/boost/random/mersenne_twister.hpp (original)
+++ trunk/boost/random/mersenne_twister.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -262,7 +262,7 @@
{ return !(x == y); }
private:
- /// \cond hide_private_members
+ /// \cond show_private
void twist();
@@ -361,7 +361,7 @@
std::size_t i;
};
-/// \cond
+/// \cond show_private
#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
// A definition is required even for integral static constants
@@ -498,8 +498,7 @@
UINT64_C(6364136223846793005)> mt19937_64;
#endif
-
-/// \cond
+/// \cond show_deprecated
template<class UIntType,
int w, int n, int m, int r,
Modified: trunk/boost/random/negative_binomial_distribution.hpp
==============================================================================
--- trunk/boost/random/negative_binomial_distribution.hpp (original)
+++ trunk/boost/random/negative_binomial_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -196,7 +196,7 @@
private:
- /// @cond
+ /// @cond \show_private
template<class CharT, class Traits>
void read(std::basic_istream<CharT, Traits>& is) {
Modified: trunk/boost/random/normal_distribution.hpp
==============================================================================
--- trunk/boost/random/normal_distribution.hpp (original)
+++ trunk/boost/random/normal_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -208,15 +208,10 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(normal_distribution)
private:
-
- /// @cond
-
RealType _mean, _sigma;
RealType _r1, _r2, _cached_rho;
bool _valid;
- /// @endcond
-
};
} // namespace random
Modified: trunk/boost/random/piecewise_constant_distribution.hpp
==============================================================================
--- trunk/boost/random/piecewise_constant_distribution.hpp (original)
+++ trunk/boost/random/piecewise_constant_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -211,19 +211,15 @@
private:
- /// @cond
-
friend class piecewise_constant_distribution;
std::vector<RealType> _intervals;
std::vector<WeightType> _weights;
-
- /// @endcond
};
/**
* Creates a new @c piecewise_constant_distribution with
- * a single interval, [0, 1)$.
+ * a single interval, [0, 1).
*/
piecewise_constant_distribution()
{
@@ -460,13 +456,8 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(piecewise_constant_distribution)
private:
-
- /// @cond
-
discrete_distribution<std::size_t, WeightType> _bins;
std::vector<RealType> _intervals;
-
- /// @endcond
};
}
Modified: trunk/boost/random/piecewise_linear_distribution.hpp
==============================================================================
--- trunk/boost/random/piecewise_linear_distribution.hpp (original)
+++ trunk/boost/random/piecewise_linear_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -225,15 +225,10 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
private:
-
- /// @cond
-
friend class piecewise_linear_distribution;
std::vector<RealType> _intervals;
std::vector<WeightType> _weights;
-
- /// @endcond
};
/**
@@ -487,7 +482,7 @@
private:
- /// @cond
+ /// @cond \show_private
void init(const std::vector<RealType>& intervals_arg,
const std::vector<WeightType>& weights_arg)
Modified: trunk/boost/random/poisson_distribution.hpp
==============================================================================
--- trunk/boost/random/poisson_distribution.hpp (original)
+++ trunk/boost/random/poisson_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -225,7 +225,7 @@
private:
- /// @cond
+ /// @cond show_private
template<class CharT, class Traits>
void read(std::basic_istream<CharT, Traits>& is) {
Modified: trunk/boost/random/random_device.hpp
==============================================================================
--- trunk/boost/random/random_device.hpp (original)
+++ trunk/boost/random/random_device.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -77,7 +77,7 @@
*
* <table cols="2">
* <tr><th>class</th><th>time per invocation [usec]</th></tr>
- * <tr><td> @xmlonly <classname alt="boost::random_device">random_device</classname> @endxmlonly </td><td>92.0</td></tr>
+ * <tr><td> \random_device </td><td>92.0</td></tr>
* </table>
*
* The measurement error is estimated at +/- 1 usec.
Modified: trunk/boost/random/seed_seq.hpp
==============================================================================
--- trunk/boost/random/seed_seq.hpp (original)
+++ trunk/boost/random/seed_seq.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -30,21 +30,37 @@
namespace boost {
namespace random {
+/**
+ * The class @c seed_seq stores a sequence of 32-bit words
+ * for seeding a \pseudo_random_number_generator. These
+ * words will be combined to fill the entire state of the
+ * generator.
+ */
class seed_seq {
public:
typedef boost::uint_least32_t result_type;
+ /** Initializes a seed_seq to hold an empty sequence. */
seed_seq() {}
#ifndef BOOST_NO_INITIALIZER_LISTS
+ /** Initializes the sequence from an initializer_list. */
template<class T>
seed_seq(const std::initializer_list<T>& il) : v(il.begin(), il.end()) {}
#endif
+ /** Initializes the sequence from an iterator range. */
template<class Iter>
seed_seq(Iter first, Iter last) : v(first, last) {}
+ /** Initializes the sequence from Boost.Range range. */
template<class Range>
explicit seed_seq(const Range& range)
: v(boost::begin(range), boost::end(range)) {}
+ /**
+ * Fills a range with 32-bit values based on the stored sequence.
+ *
+ * Requires: Iter must be a Random Access Iterator whose value type
+ * is an unsigned integral type at least 32 bits wide.
+ */
template<class Iter>
void generate(Iter first, Iter last) const
{
@@ -87,7 +103,9 @@
*(first + k%n) = r4;
}
}
+ /** Returns the size of the sequence. */
std::size_t size() const { return v.size(); }
+ /** Writes the stored sequence to iter. */
template<class Iter>
void param(Iter out) { std::copy(v.begin(), v.end(), out); }
private:
Modified: trunk/boost/random/shuffle_order.hpp
==============================================================================
--- trunk/boost/random/shuffle_order.hpp (original)
+++ trunk/boost/random/shuffle_order.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -233,7 +233,7 @@
private:
- /// \cond
+ /// \cond show_private
void init()
{
@@ -260,7 +260,6 @@
const std::size_t shuffle_order_engine<URNG, k>::buffer_size;
#endif
-// validation by experiment from Harry Erwin's generator.h (private e-mail)
/**
* According to Harry Erwin (private e-mail), the specialization
* @c kreutzer1986 was suggested in:
@@ -274,6 +273,15 @@
linear_congruential_engine<uint32_t, 1366, 150889, 714025>,
97> kreutzer1986;
+/**
+ * The specialization @c knuth_b is specified by the C++ standard.
+ * It is described in
+ *
+ * @blockquote
+ * "The Art of Computer Programming, Second Edition, Volume 2,
+ * Seminumerical Algorithms", Donald Knuth, Addison-Wesley, 1981.
+ * @endblockquote
+ */
typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
} // namespace random
Modified: trunk/boost/random/student_t_distribution.hpp
==============================================================================
--- trunk/boost/random/student_t_distribution.hpp (original)
+++ trunk/boost/random/student_t_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -31,7 +31,7 @@
* It has \f$\displaystyle p(x) =
* \frac{1}{\sqrt{n\pi}}
* \frac{\Gamma((n+1)/2)}{\Gamma(n/2)}
- * \left(1}\frac{x^2}{n}\right)^{-(n+1)/2}
+ * \left(1+\frac{x^2}{n}\right)^{-(n+1)/2}
* \f$.
*/
template<class RealType = double>
Modified: trunk/boost/random/subtract_with_carry.hpp
==============================================================================
--- trunk/boost/random/subtract_with_carry.hpp (original)
+++ trunk/boost/random/subtract_with_carry.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -225,7 +225,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(subtract_with_carry_engine)
private:
- /// \cond
+ /// \cond show_private
// returns x(i-r+index), where index is in 0..r-1
IntType compute(unsigned int index) const
{
@@ -270,7 +270,17 @@
// use a floating-point representation to produce values in [0..1)
-/** @copydoc boost::random::subtract_with_carry_engine */
+/**
+ * Instantiations of \subtract_with_carry_01_engine model a
+ * \pseudo_random_number_generator. The algorithm is
+ * described in
+ *
+ * @blockquote
+ * "A New Class of Random Number Generators", George
+ * Marsaglia and Arif Zaman, Annals of Applied Probability,
+ * Volume 1, Number 3 (1991), 462-480.
+ * @endblockquote
+ */
template<class RealType, std::size_t w, std::size_t s, std::size_t r>
class subtract_with_carry_01_engine
{
@@ -284,21 +294,21 @@
BOOST_STATIC_ASSERT(!std::numeric_limits<result_type>::is_integer);
- /** Creates a new subtract_with_carry_01_engine using the default seed. */
+ /** Creates a new \subtract_with_carry_01_engine using the default seed. */
subtract_with_carry_01_engine() { init_modulus(); seed(); }
/** Creates a new subtract_with_carry_01_engine and seeds it with value. */
BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(subtract_with_carry_01_engine,
uint32_t, value)
{ init_modulus(); seed(value); }
/**
- * Creates a new subtract_with_carry_01_engine and seeds with with values
+ * Creates a new \subtract_with_carry_01_engine and seeds with with values
* produced by seq.generate().
*/
BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(subtract_with_carry_01_engine,
SeedSeq, seq)
{ init_modulus(); seed(seq); }
/**
- * Creates a new subtract_with_carry_01_engine and seeds it with values
+ * Creates a new \subtract_with_carry_01_engine and seeds it with values
* from a range. Advances first to point one past the last consumed
* value. If the range does not contain enough elements to fill the
* entire state, throws @c std::invalid_argument.
@@ -307,7 +317,7 @@
{ init_modulus(); seed(first,last); }
private:
- /// \cond
+ /// \cond show_private
void init_modulus()
{
#ifndef BOOST_NO_STDC_NAMESPACE
@@ -433,7 +443,7 @@
}
}
- /** Writes a subtract_with_carry_01_engine to a @c std::ostream. */
+ /** Writes a \subtract_with_carry_01_engine to a @c std::ostream. */
BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, subtract_with_carry_01_engine, f)
{
std::ios_base::fmtflags oldflags =
@@ -445,7 +455,7 @@
return os;
}
- /** Reads a subtract_with_carry_01_engine from a @c std::istream. */
+ /** Reads a \subtract_with_carry_01_engine from a @c std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, subtract_with_carry_01_engine, f)
{
RealType value;
@@ -472,7 +482,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(subtract_with_carry_01_engine)
private:
- /// \cond
+ /// \cond show_private
RealType compute(unsigned int index) const
{
return x[(k+index) % long_lag];
@@ -499,7 +509,7 @@
#endif
-/// \cond
+/// \cond show_deprecated
template<class IntType, IntType m, unsigned s, unsigned r, IntType v>
class subtract_with_carry :
Modified: trunk/boost/random/triangle_distribution.hpp
==============================================================================
--- trunk/boost/random/triangle_distribution.hpp (original)
+++ trunk/boost/random/triangle_distribution.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -207,7 +207,7 @@
BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(triangle_distribution)
private:
- /// \cond
+ /// \cond show_private
void init()
{
using std::sqrt;
Modified: trunk/boost/random/uniform_01.hpp
==============================================================================
--- trunk/boost/random/uniform_01.hpp (original)
+++ trunk/boost/random/uniform_01.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -26,6 +26,7 @@
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
+namespace random {
#ifdef BOOST_RANDOM_DOXYGEN
@@ -266,6 +267,10 @@
#endif
+} // namespace random
+
+using random::uniform_01;
+
} // namespace boost
#include <boost/random/detail/enable_warnings.hpp>
Modified: trunk/boost/random/uniform_smallint.hpp
==============================================================================
--- trunk/boost/random/uniform_smallint.hpp (original)
+++ trunk/boost/random/uniform_smallint.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -63,7 +63,8 @@
*
* The template parameter IntType shall denote an integer-like value type.
*
- * Note: The property above is the square sum of the relative differences
+ * @xmlnote
+ * The property above is the square sum of the relative differences
* in probabilities between the desired uniform distribution
* \f$p_{\mathtt{out}}(i)\f$ and the generated distribution
* \f$p_{\mathtt{out\_s}}(i)\f$.
@@ -85,6 +86,7 @@
* {r_{\mathtt{out}}}\right\rfloor/r_{\mathtt{base}}\f$ otherwise.
* Substituting this in the
* above sum formula leads to the desired result.
+ * @endxmlnote
*
* Note: The upper bound for
* \f$(r_{\mathtt{base}} \mbox{ mod } r_{\mathtt{out}})
@@ -228,7 +230,7 @@
private:
- // \cond
+ // \cond show_private
template<class Engine>
result_type generate(Engine& eng, boost::mpl::true_) const
{
Modified: trunk/boost/random/variate_generator.hpp
==============================================================================
--- trunk/boost/random/variate_generator.hpp (original)
+++ trunk/boost/random/variate_generator.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -33,9 +33,6 @@
* Boost.Random provides a vast choice of \generators as well
* as \distributions.
*
- * Instantations of class template @c variate_generator model
- * a \number_generator.
- *
* The argument for the template parameter Engine shall be of
* the form U, U&, or U*, where U models a
* \uniform_random_number_generator. Then, the member
Modified: trunk/boost/random/xor_combine.hpp
==============================================================================
--- trunk/boost/random/xor_combine.hpp (original)
+++ trunk/boost/random/xor_combine.hpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -176,7 +176,7 @@
const int xor_combine_engine<URNG1, s1, URNG2, s2>::shift2;
#endif
-/// \cond
+/// \cond show_private
/** Provided for backwards compatibility. */
template<class URNG1, int s1, class URNG2, int s2,
Modified: trunk/libs/random/doc/Jamfile.v2
==============================================================================
--- trunk/libs/random/doc/Jamfile.v2 (original)
+++ trunk/libs/random/doc/Jamfile.v2 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -19,30 +19,40 @@
bernoulli_distribution
binomial_distribution
cauchy_distribution
+ chi_squared_distribution
discard_block
discrete_distribution
exponential_distribution
extreme_value_distribution
+ fisher_f_distribution
gamma_distribution
geometric_distribution
+ independent_bits
inversive_congruential
lagged_fibonacci
linear_congruential
linear_feedback_shift
lognormal_distribution
mersenne_twister
+ negative_binomial_distribution
normal_distribution
+ piecewise_constant_distribution
+ piecewise_linear_distribution
poisson_distribution
+ random_device
random_number_generator
ranlux
+ seed_seq
shuffle_order
# shuffle_output
+ student_t_distribution
subtract_with_carry
+ taus88
triangle_distribution
uniform_01
- uniform_int
+ uniform_int_distribution
uniform_on_sphere
- uniform_real
+ uniform_real_distribution
uniform_smallint
variate_generator
weibull_distribution
@@ -62,7 +72,6 @@
doxygen reference :
$(here)/../../../boost/random/$(doxygen_files).hpp
- $(here)/../../../boost/nondet_random.hpp
$(here)/../../../boost/random.hpp
:
<doxygen:param>EXPAND_ONLY_PREDEF=YES
@@ -78,25 +87,25 @@
pseudo_random_number_generator=\"@xmlonly <link linkend=\\\"boost_random.reference.concepts.pseudo_random_number_generator\\\">pseudo-random number generator</link> @endxmlonly\" \\
uniform_random_number_generator=\"@xmlonly <link linkend=\\\"boost_random.reference.concepts.uniform_random_number_generator\\\">uniform random number generator</link> @endxmlonly\" \\
nondeterministic_random_number_generator=\"@xmlonly <link linkend=\\\"boost_random.reference.concepts.non_deterministic_uniform_random_number_generator\\\">non-deterministic random number generator</link> @endxmlonly\" \\
- number_generator=\"@xmlonly <link linkend=\\\"boost_random.reference.concepts.number_generator\\\">number generator</link> @endxmlonly\" \\
generators=\"@xmlonly <link linkend=\\\"boost_random.reference.generators\\\">generators</link> @endxmlonly\" \\
distributions=\"@xmlonly <link linkend=\\\"boost_random.reference.distributions\\\">distributions</link> @endxmlonly\" \\
- additive_combine=\"@xmlonly <classname alt=\\\"boost::random::additive_combine\\\">additive_combine</classname> @endxmlonly\" \\
+ additive_combine_engine=\"@xmlonly <classname alt=\\\"boost::random::additive_combine_engine\\\">additive_combine_engine</classname> @endxmlonly\" \\
discard_block_engine=\"@xmlonly <classname alt=\\\"boost::random::discard_block_engine\\\">discard_block_engine</classname> @endxmlonly\" \\
- lagged_fibonacci=\"@xmlonly<classname alt=\\\"boost::random::lagged_fibonacci\\\">lagged_fibonacci</classname>@endxmlonly\" \\
+ lagged_fibonacci_engine=\"@xmlonly<classname alt=\\\"boost::random::lagged_fibonacci_engine\\\">lagged_fibonacci_engine</classname>@endxmlonly\" \\
+ subtract_with_carry_01_engine=\"@xmlonly<classname alt=\\\"boost::random::subtract_with_carry_01_engine\\\">subtract_with_carry_01_engine</classname>@endxmlonly\" \\
linear_congruential_engine=\"@xmlonly<classname alt=\\\"boost::random::linear_congruential_engine\\\">linear_congruential_engine</classname>@endxmlonly\" \\
minstd_rand=\"@xmlonly <classname alt=\\\"boost::random::minstd_rand\\\">minstd_rand</classname> @endxmlonly\" \\
minstd_rand0=\"@xmlonly <classname alt=\\\"boost::random::minstd_rand0\\\">minstd_rand0</classname> @endxmlonly\" \\
rand48=\"@xmlonly <classname alt=\\\"boost::random::rand48\\\">rand48</classname> @endxmlonly\" \\
mt11213b=\"@xmlonly <classname alt=\\\"boost::random::mt11213b\\\">mt11213b</classname> @endxmlonly\" \\
mt19937=\"@xmlonly <classname alt=\\\"boost::random::mt19937\\\">mt19937</classname> @endxmlonly\" \\
- ecuyer1988=\"@xmlonly <classname alt=\\\"boost::ecuyer1988\\\">ecuyer1988</classname> @endxmlonly\" \\
- lagged_fibonacci607=\"@xmlonly <classname alt=\\\"boost::lagged_fibonacci607\\\">lagged_fibonacci607</classname> @endxmlonly\" \\
- lagged_fibonacci44497=\"@xmlonly <classname alt=\\\"boost::lagged_fibonacci44497\\\">lagged_fibonacci44497</classname> @endxmlonly\" \\
- bernoulli_distribution=\"@xmlonly <classname alt=\\\"boost::bernoulli_distribution\\\">bernoulli_distribution</classname> @endxmlonly\" \\
- cauchy_distribution=\"@xmlonly <classname alt=\\\"boost::cauchy_distribution\\\">cauchy_distribution</classname> @endxmlonly\" \\
- uniform_01=\"@xmlonly<classname alt=\\\"boost::uniform_01\\\">uniform_01</classname>@endxmlonly\" \\
- random_device=\"@xmlonly<classname alt=\\\"boost::random_device\\\">random_device</classname>@endxmlonly\""
+ ecuyer1988=\"@xmlonly <classname alt=\\\"boost::random::ecuyer1988\\\">ecuyer1988</classname> @endxmlonly\" \\
+ lagged_fibonacci607=\"@xmlonly <classname alt=\\\"boost::random::lagged_fibonacci607\\\">lagged_fibonacci607</classname> @endxmlonly\" \\
+ lagged_fibonacci44497=\"@xmlonly <classname alt=\\\"boost::random::lagged_fibonacci44497\\\">lagged_fibonacci44497</classname> @endxmlonly\" \\
+ bernoulli_distribution=\"@xmlonly <classname alt=\\\"boost::random::bernoulli_distribution\\\">bernoulli_distribution</classname> @endxmlonly\" \\
+ cauchy_distribution=\"@xmlonly <classname alt=\\\"boost::random::cauchy_distribution\\\">cauchy_distribution</classname> @endxmlonly\" \\
+ uniform_01=\"@xmlonly<classname alt=\\\"boost::random::uniform_01\\\">uniform_01</classname>@endxmlonly\" \\
+ random_device=\"@xmlonly<classname alt=\\\"boost::random::random_device\\\">random_device</classname>@endxmlonly\""
<doxygen:param>HIDE_UNDOC_MEMBERS=NO
<doxygen:param>QUIET=YES
<doxygen:param>WARN_IF_UNDOCUMENTED=NO
@@ -125,10 +134,16 @@
\"b_arg=b\" \\
\"c_arg=c\" \\
\"t_arg=t\" \\
+ \"m_arg=m\" \\
+ \"n_arg=n\" \\
+ \"s_arg=s\" \\
+ \"k_arg=k\" \\
\"min_arg=min\" \\
\"max_arg=max\" \\
+ \"dim_arg=dim\" \\
\"parm=param\" \\
\"aseed=seed\" \\
+ \"seed_arg=seed\" \\
\"BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os,T,t)=template<class CharT, class Traits> friend std::basic_ostream<CharT,Traits>& operator<<(std::basic_ostream<CharT,Traits>& os, const T& t)\" \\
\"BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is,T,t)=template<class CharT, class Traits> friend std::basic_istream<CharT,Traits>& operator>>(std::basic_istream<CharT,Traits>& is, const T& t)\" \\
\"BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(T,lhs,rhs)=friend bool operator==(const T& lhs, const T& rhs)\" \\
Modified: trunk/libs/random/doc/concepts.qbk
==============================================================================
--- trunk/libs/random/doc/concepts.qbk (original)
+++ trunk/libs/random/doc/concepts.qbk 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -31,42 +31,21 @@
* pseudo-random number generator
* quasi-random number generator
-All variations have some properties in common, these concepts (in the STL
-sense) are called __NumberGenerator and __UniformRandomNumberGenerator. Each
-concept will be defined in a subsequent section.
+All variations have some properties in common, the concepts (in the STL
+sense) is called __UniformRandomNumberGenerator. This
+concept will be defined in a subsequent section.
The goals for this library are the following:
-* allow easy integration of third-party random-number generators
-* define a validation interface for the generators
+* allow easy integration of third-party random-number generators
* provide easy-to-use front-end classes which model popular distributions
* provide maximum efficiency
-* allow control on quantization effects in front-end processing (not yet done)
-
-[endsect]
-
-[section Number Generator]
-
-A number generator is a /function object/ (std:20.3 [lib.function.objects]) that
-takes zero arguments. Each call to `operator()` returns a number. In the
-following table, X denotes a number generator class returning objects of type
-T, and u is a value of X.
-
-[table NumberGenerator requirements
- [[expression] [return type] [pre/post-condition]]
- [[`X::result_type`] [`T`] [`std::numeric_limits<T>::is_specialized` is
- `true`, `T` is __LessThanComparable]]
- [[`u.operator()()`] [`T`] [-]]
-]
-
-[note The NumberGenerator requirements do not impose any restrictions on the
-characteristics of the returned numbers.]
[endsect]
[section Uniform Random Number Generator]
-A uniform random number generator is a __NumberGenerator that provides a
+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.
@@ -81,18 +60,9 @@
[table UniformRandomNumberGenerator requirements
[[expression] [return type] [pre/post-condition]]
- [[`X::has_fixed_range`] [`bool`] [compile-time constant; if `true`, the range
- on which the random numbers are uniformly
- distributed is known at compile-time and
- members `min_value` and `max_value` exist.
- Note: This flag may also be `false` due to
- compiler limitations]]
- [[`X::min_value`] [`T`] [compile-time constant; `min_value` is only defined if
- `has_fixed_range` is `true`. If it exists, it is
- equal to `v.min()`.]]
- [[`X::max_value`] [`T`] [compile-time constant; `max_value` is only defined if
- `has_fixed_range` is `true`. If it exists, it is
- equal to `v.max()`]]
+ [[`X::result_type`] [`T`] [`std::numeric_limits<T>::is_specialized` is
+ `true`, `T` is __LessThanComparable]]
+ [[`u.operator()()`] [`T`] [-]]
[[`v.min()`] [`T`] [tight lower bound on the set of all values returned by
`operator()`. The return value of this function shall not
change during the lifetime of the object.]]
@@ -160,7 +130,7 @@
provides a deterministic sequence of pseudo-random numbers, based on some
algorithm and internal state.
[classref boost::random::linear_congruential_engine
-Linear congruential] and [classref boost::random::inversive_congruential
+Linear congruential] and [classref boost::random::inversive_congruential_engine
inversive congruential] generators are examples of such [prng pseudo-random
number generators]. Often, these generators are very sensitive to their
parameters. In order to prevent wrong implementations from being used, an
@@ -187,20 +157,13 @@
[[`X()`] [-] [creates a generator in some implementation-defined state.
Note: Several generators thusly created may possibly produce
dependent or identical sequences of random numbers.]]
- [[`explicit X(...)`] [-] [creates a generator with user-provided state; the
+ [[`X(...)`] [-] [creates a generator with user-provided state; the
implementation shall specify the constructor
argument(s)]]
[[`u.seed(...)`] [`void`] [sets the current state according to the
argument(s); at least functions with the same
signature as the non-default constructor(s)
shall be provided.]]
- [[`X::validation(x)`] [`bool`] [compares the pre-computed and hardcoded
- 10001th element in the generator's random
- number sequence with x. The generator must
- have been constructed by its default
- constructor and seed must not have been
- called for the validation to be
- meaningful.]]
]
[note The seed member function is similar to the assign member function in
@@ -220,7 +183,7 @@
pseudo-random number generator with the restored state and the original at
the just-written state shall be equivalent.
-Classes which model a pseudo-random number generator may also model the
+Classes which model a pseudo-random number generator should also model the
__CopyConstructible and __Assignable 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.
@@ -248,16 +211,16 @@
`e` is an lvalue of an arbitrary type that meets the requirements of a
__UniformRandomNumberGenerator, returning values of type `U`.
-[table Random distribution requirements (in addition to NumberGenerator, CopyConstructible, and Assignable)
+[table Random distribution requirements (in addition to CopyConstructible, and Assignable)
[[expression] [return type] [pre/post-condition] [complexity]]
- [[`X::input_type`] [`U`] [-] [compile-time]]
+ [[`X::result_type`] [`T`] [-] [compile-time]]
[[`u.reset()`] [`void`] [subsequent uses of `u` do not depend on values
- produced by `e` prior to invoking `reset`.]
+ produced by any engine prior to invoking `reset`.]
[constant]]
[[`u(e)`] [`T`] [the sequence of numbers returned by successive invocations
with the same object `e` is randomly distributed with some
probability density function `p(x)`]
- [amortized constant number of invocations of `e`]]
+ [amortized constant number of invocations of `e`]]
[[`os << x`] [`std::ostream&`] [writes a textual representation for the
parameters and additional internal data of
the distribution `x` to `os`.
Modified: trunk/libs/random/doc/distributions.qbk
==============================================================================
--- trunk/libs/random/doc/distributions.qbk (original)
+++ trunk/libs/random/doc/distributions.qbk 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -18,24 +18,28 @@
values of the specified distribution or otherwise do not converge
statistically to it are not acceptable.
-[table distributions
+[table Uniform Distributions
[[distribution] [explanation] [example]]
[[__uniform_smallint] [discrete uniform distribution on a small set of integers
(much smaller than the range of the underlying
generator)]
[drawing from an urn]]
- [[__uniform_int] [discrete uniform distribution on a set of integers; the
+ [[__uniform_int_distribution] [discrete uniform distribution on a set of integers; the
underlying generator may be called several times to gather
enough randomness for the output]
[drawing from an urn]]
[[__uniform_01] [continuous uniform distribution on the range [0,1);
important basis for other distributions]
[-]]
- [[__uniform_real] [continuous uniform distribution on some range [min, max) of
+ [[__uniform_real_distribution] [continuous uniform distribution on some range [min, max) of
real numbers]
[for the range [0, 2pi): randomly dropping a stick and
measuring its angle in radians (assuming the angle is
uniformly distributed)]]
+]
+
+[table Bernoulli Distributions
+ [[distribution] [explanation] [example]]
[[__bernoulli_distribution] [Bernoulli experiment: discrete boolean valued
distribution with configurable probability]
[tossing a coin (p=0.5)]]
@@ -43,21 +47,33 @@
experiments]
[tossing a coin 20 times and counting how many
front sides are shown]]
- [[__cauchy_distribution][cauchy distribution][-]]
- [[__discrete_distribution][discrete distribution with specific probabilities][rolling an unfair die]]
- [[__gamma_distribution][gamma distribution][-]]
- [[__poisson_distribution][poisson distribution]
- [counting the number of alpha particles emitted
- by radioactive matter in a fixed period of time]]
[[__geometric_distribution] [measures distance between outcomes of repeated
Bernoulli experiments]
[throwing a die several times and counting the
number of tries until a "6" appears for the
first time]]
- [[__triangle_distribution] [triangle distribution] [-]]
+ [[__negative_binomial_distribution] [Counts the number of failures of repeated
+ Bernoulli experiments required to get some constant
+ number of successes.]
+ [flipping a coin and counting the number of
+ heads that show up before we get 3 tails]]
+]
+
+[table Poisson Distributions
+ [[distribution] [explanation] [example]]
+ [[__poisson_distribution][poisson distribution]
+ [counting the number of alpha particles emitted
+ by radioactive matter in a fixed period of time]]
[[__exponential_distribution] [exponential distribution]
[measuring the inter-arrival time of alpha
particles emitted by radioactive matter]]
+ [[__gamma_distribution][gamma distribution][-]]
+ [[__weibull_distribution] [weibull distribution] [-]]
+ [[__extreme_value_distribution] [extreme value distribution] [-]]
+]
+
+[table Normal Distributions
+ [[distribution] [explanation] [example]]
[[__normal_distribution] [counts outcomes of (infinitely) repeated Bernoulli
experiments]
[tossing a coin 10000 times and counting how many
@@ -66,8 +82,23 @@
simulations)]
[measuring the job completion time of an assembly
line worker]]
- [[__weibull_distribution] [weibull distribution] [-]]
- [[__extreme_value_distribution] [extreme value distribution] [-]]
+ [[__chi_squared_distribution][chi-squared distribution][-]]
+ [[__cauchy_distribution][Cauchy distribution][-]]
+ [[__fisher_f_distribution][Fisher F distribution][-]]
+ [[__student_t_distribution][Student t distribution][-]]
+]
+
+[table Sampling Distributions
+ [[distribution] [explanation] [example]]
+ [[__discrete_distribution][discrete distribution with specific probabilities][rolling an unfair die]]
+ [[__piecewise_constant_distribution][-][-]]
+ [[__piecewise_linear_distribution][-][-]]
+]
+
+
+[table Miscellaneous Distributions
+ [[distribution] [explanation] [example]]
+ [[__triangle_distribution] [triangle distribution] [-]]
[[__uniform_on_sphere] [uniform distribution on a unit sphere of arbitrary
dimension]
[choosing a random point on Earth (assumed to be a
Modified: trunk/libs/random/doc/random.qbk
==============================================================================
--- trunk/libs/random/doc/random.qbk (original)
+++ trunk/libs/random/doc/random.qbk 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -26,30 +26,30 @@
[def __EqualityComparable [@boost:/doc/html/EqualityComparable.html EqualityComparable]]
[def __Streamable Streamable]
-[def __random_device [classref boost::random_device random_device]]
+[def __random_device [classref boost::random::random_device random_device]]
[def __random_number_generator [classref boost::random_number_generator random_number_generator]]
[def __variate_generator [classref boost::variate_generator variate_generator]]
[def __minstd_rand0 [classref boost::random::minstd_rand0 minstd_rand0]]
[def __minstd_rand [classref boost::random::minstd_rand minstd_rand]]
[def __rand48 [classref boost::random::rand48 rand48]]
-[def __ecuyer1988 [classref boost::ecuyer1988 ecuyer1988]]
+[def __ecuyer1988 [classref boost::random::ecuyer1988 ecuyer1988]]
[def __kreutzer1986 [classref boost::random::kreutzer1986 kreutzer1986]]
[def __knuth_b [classref boost::random::knuth_b knuth_b]]
-[def __taus88 [classref boost::taus88 taus88]]
-[def __hellekalek1995 [classref boost::hellekalek1995 hellekalek1995]]
+[def __taus88 [classref boost::random::taus88 taus88]]
+[def __hellekalek1995 [classref boost::random::hellekalek1995 hellekalek1995]]
[def __mt11213b [classref boost::random::mt11213b mt11213b]]
[def __mt19937 [classref boost::random::mt19937 mt19937]]
[def __mt19937_64 [classref boost::random::mt19937_64 mt19937_64]]
-[def __lagged_fibonacci607 [classref boost::lagged_fibonacci607 lagged_fibonacci607]]
-[def __lagged_fibonacci1279 [classref boost::lagged_fibonacci1279 lagged_fibonacci1279]]
-[def __lagged_fibonacci2281 [classref boost::lagged_fibonacci2281 lagged_fibonacci2281]]
-[def __lagged_fibonacci3217 [classref boost::lagged_fibonacci3217 lagged_fibonacci3217]]
-[def __lagged_fibonacci4423 [classref boost::lagged_fibonacci4423 lagged_fibonacci4423]]
-[def __lagged_fibonacci9689 [classref boost::lagged_fibonacci9689 lagged_fibonacci9689]]
-[def __lagged_fibonacci19937 [classref boost::lagged_fibonacci19937 lagged_fibonacci19937]]
-[def __lagged_fibonacci23209 [classref boost::lagged_fibonacci23209 lagged_fibonacci23209]]
-[def __lagged_fibonacci44497 [classref boost::lagged_fibonacci44497 lagged_fibonacci44497]]
+[def __lagged_fibonacci607 [classref boost::random::lagged_fibonacci607 lagged_fibonacci607]]
+[def __lagged_fibonacci1279 [classref boost::random::lagged_fibonacci1279 lagged_fibonacci1279]]
+[def __lagged_fibonacci2281 [classref boost::random::lagged_fibonacci2281 lagged_fibonacci2281]]
+[def __lagged_fibonacci3217 [classref boost::random::lagged_fibonacci3217 lagged_fibonacci3217]]
+[def __lagged_fibonacci4423 [classref boost::random::lagged_fibonacci4423 lagged_fibonacci4423]]
+[def __lagged_fibonacci9689 [classref boost::random::lagged_fibonacci9689 lagged_fibonacci9689]]
+[def __lagged_fibonacci19937 [classref boost::random::lagged_fibonacci19937 lagged_fibonacci19937]]
+[def __lagged_fibonacci23209 [classref boost::random::lagged_fibonacci23209 lagged_fibonacci23209]]
+[def __lagged_fibonacci44497 [classref boost::random::lagged_fibonacci44497 lagged_fibonacci44497]]
[def __ranlux3 [classref boost::random::ranlux3 ranlux3]]
[def __ranlux4 [classref boost::random::ranlux4 ranlux4]]
[def __ranlux64_3 [classref boost::random::ranlux64_3 ranlux64_3]]
@@ -61,24 +61,30 @@
[def __ranlux24 [classref boost::random::ranlux24 ranlux24]]
[def __ranlux48 [classref boost::random::ranlux48 ranlux48]]
-[def __uniform_smallint [classref boost::uniform_smallint uniform_smallint]]
-[def __uniform_int [classref boost::uniform_int uniform_int]]
-[def __uniform_01 [classref boost::uniform_01 uniform_01]]
-[def __uniform_real [classref boost::uniform_real uniform_real]]
-[def __bernoulli_distribution [classref boost::bernoulli_distribution bernoulli_distribution]]
+[def __uniform_smallint [classref boost::random::uniform_smallint uniform_smallint]]
+[def __uniform_int_distribution [classref boost::random::uniform_int_distribution uniform_int_distribution]]
+[def __uniform_01 [classref boost::random::uniform_01 uniform_01]]
+[def __uniform_real_distribution [classref boost::random::uniform_real_distribution uniform_real_distribution]]
+[def __bernoulli_distribution [classref boost::random::bernoulli_distribution bernoulli_distribution]]
[def __binomial_distribution [classref boost::random::binomial_distribution binomial_distribution]]
-[def __cauchy_distribution [classref boost::cauchy_distribution cauchy_distribution]]
+[def __cauchy_distribution [classref boost::random::cauchy_distribution cauchy_distribution]]
[def __discrete_distribution [classref boost::random::discrete_distribution discrete_distribution]]
[def __gamma_distribution [classref boost::random::gamma_distribution gamma_distribution]]
[def __poisson_distribution [classref boost::random::poisson_distribution poisson_distribution]]
-[def __geometric_distribution [classref boost::geometric_distribution geometric_distribution]]
-[def __triangle_distribution [classref boost::triangle_distribution triangle_distribution]]
-[def __exponential_distribution [classref boost::exponential_distribution exponential_distribution]]
-[def __normal_distribution [classref boost::normal_distribution normal_distribution]]
-[def __lognormal_distribution [classref boost::lognormal_distribution lognormal_distribution]]
-[def __uniform_on_sphere [classref boost::uniform_on_sphere uniform_on_sphere]]
+[def __geometric_distribution [classref boost::random::geometric_distribution geometric_distribution]]
+[def __triangle_distribution [classref boost::random::triangle_distribution triangle_distribution]]
+[def __exponential_distribution [classref boost::random::exponential_distribution exponential_distribution]]
+[def __normal_distribution [classref boost::random::normal_distribution normal_distribution]]
+[def __lognormal_distribution [classref boost::random::lognormal_distribution lognormal_distribution]]
+[def __uniform_on_sphere [classref boost::random::uniform_on_sphere uniform_on_sphere]]
[def __weibull_distribution [classref boost::random::weibull_distribution weibull_distribution]]
[def __extreme_value_distribution [classref boost::random::extreme_value_distribution extreme_value_distribution]]
+[def __negative_binomial_distribution [classref boost::random::negative_binomial_distribution negative_binomial_distribution]]
+[def __student_t_distribution [classref boost::random::student_t_distribution student_t_distribution]]
+[def __fisher_f_distribution [classref boost::random::fisher_f_distribution fisher_f_distribution]]
+[def __chi_squared_distribution [classref boost::random::chi_squared_distribution chi_squared_distribution]]
+[def __piecewise_constant_distribution [classref boost::random::piecewise_constant_distribution piecewise_constant_distribution]]
+[def __piecewise_linear_distribution [classref boost::random::piecewise_linear_distribution piecewise_linear_distribution]]
[include performance_data.qbk]
@@ -97,11 +103,10 @@
``[classref boost::random::mt19937]`` rng; // produces randomness out of thin air
// see pseudo-random number generators
- ``[classref boost::uniform_int]<>`` six(1,6); // distribution that maps to 1..6
+ ``[classref boost::random::uniform_int_distribution]<>`` six(1,6);
+ // distribution that maps to 1..6
// see random number distributions
- ``[classref boost::variate_generator]``<``[classref boost::random::mt19937]``&, ``[classref boost::uniform_int]``<> >
- die(rng, six); // glues randomness with mapping
- int x = die(); // simulate rolling a die
+ int x = six(rng); // simulate rolling a die
[endsect]
@@ -131,17 +136,6 @@
[include performance.qbk]
[endsect]
-[section Rationale]
-
-The methods for generating and evaluating deterministic and non-deterministic
-random numbers differ radically. Furthermore, due to the inherent
-deterministic design of present-day computers, it is often difficult to
-implement non-deterministic random number generation facilities. Thus, the
-random number library is split into separate header files, mirroring the two
-different application domains.
-
-[endsect]
-
[section History and Acknowledgements]
In November 1999, Jeet Sukumaran proposed a framework based on virtual
Modified: trunk/libs/random/example/die.cpp
==============================================================================
--- trunk/libs/random/example/die.cpp (original)
+++ trunk/libs/random/example/die.cpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -12,11 +12,10 @@
For the source of this example see
[@boost://libs/random/example/die.cpp die.cpp].
First we include the headers we need for __mt19937
- and __uniform_int.
+ and __uniform_int_distribution.
*/
#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_int.hpp>
-#include <boost/random/variate_generator.hpp>
+#include <boost/random/uniform_int_distribution.hpp>
/*`
We use __mt19937 with the default seed as a source of
@@ -38,24 +37,17 @@
int roll_die() {
/*<< __mt19937 produces integers in the range [0, 2[sup 32]-1].
However, we want numbers in the range [1, 6]. The distribution
- __uniform_int performs this transformation.
- [warning Contrary to common C++ usage __uniform_int
+ __uniform_int_distribution performs this transformation.
+ [warning Contrary to common C++ usage __uniform_int_distribution
does not take a /half-open range/. Instead it takes a /closed range/.
- Given the parameters 1 and 6, __uniform_int can
+ Given the parameters 1 and 6, __uniform_int_distribution can
can produce any of the values 1, 2, 3, 4, 5, or 6.]
>>*/
- boost::uniform_int<> dist(1, 6);
- /*<< __variate_generator combines a generator with a distribution.
- [important We pass [classref boost::random::mt19937 boost::mt19937&] to
- __variate_generator instead of just [classref boost::random::mt19937]
- (note the reference). Without the reference, __variate_generator
- would make a copy of the generator and would leave the global
- `gen` unchanged. Consequently, `roll_die` would produce *the same value*
- every time it was called.]
+ boost::random::uniform_int_distribution<> dist(1, 6);
+ /*<< A distribution is a function object. We generate a random
+ number by calling `dist` with the generator.
>>*/
- boost::variate_generator<boost::random::mt19937&, boost::uniform_int<> > die(gen, dist);
- /*<< A __variate_generator is a function object. >>*/
- return die();
+ return dist(gen);
}
//]
Modified: trunk/libs/random/example/password.cpp
==============================================================================
--- trunk/libs/random/example/password.cpp (original)
+++ trunk/libs/random/example/password.cpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -17,9 +17,8 @@
*/
-#include <boost/nondet_random.hpp>
-#include <boost/random/variate_generator.hpp>
-#include <boost/random/uniform_int.hpp>
+#include <boost/random/random_device.hpp>
+#include <boost/random/uniform_int_distribution.hpp>
int main() {
/*<< We first define the characters that we're going
@@ -35,14 +34,13 @@
/*<< We use __random_device as a source of entropy, since we want
passwords that are not predictable.
>>*/
- boost::random_device rng;
+ boost::random::random_device rng;
/*<< Finally we select 8 random characters from the
string and print them to cout.
>>*/
- boost::variate_generator<boost::random_device&, boost::uniform_int<> >
- gen(rng, boost::uniform_int<>(0, chars.size()));
+ boost::random::uniform_int_distribution<> index_dist(0, chars.size() - 1);
for(int i = 0; i < 8; ++i) {
- std::cout << chars[gen()];
+ std::cout << chars[index_dist(rng)];
}
std::cout << std::endl;
}
Modified: trunk/libs/random/example/weighted_die.cpp
==============================================================================
--- trunk/libs/random/example/weighted_die.cpp (original)
+++ trunk/libs/random/example/weighted_die.cpp 2011-02-12 22:28:59 EST (Sat, 12 Feb 2011)
@@ -13,12 +13,7 @@
[@boost://libs/random/example/weighted_die.cpp weighted_die.cpp].
*/
#include <boost/random/mersenne_twister.hpp>
-#include <boost/random/uniform_real.hpp>
-#include <boost/random/variate_generator.hpp>
-#include <vector>
-#include <algorithm>
-#include <numeric>
-#include <iterator>
+#include <boost/random/discrete_distribution.hpp>
boost::mt19937 gen;
@@ -26,27 +21,27 @@
This time, instead of a fair die, the probability of
rolling a 1 is 50% (!). The other five faces are all
equally likely.
+
+ __discrete_distribution works nicely here by allowing
+ us to assign weights to each of the possible outcomes.
+
+ [tip If your compiler supports `std::initializer_list`,
+ you can initialize __discrete_distribution directly with
+ the weights.]
*/
-static const double probabilities[] = {
+double probabilities[] = {
0.5, 0.1, 0.1, 0.1, 0.1, 0.1
};
+boost::random::discrete_distribution<> dist(probabilities);
/*`
Now define a function that simulates rolling this die.
- Note that the C++0x library contains a `discrete_distribution`
- class which would be a better way to do this.
*/
int roll_weighted_die() {
- std::vector<double> cumulative;
- std::partial_sum(&probabilities[0], &probabilities[0] + 6,
- std::back_inserter(cumulative));
- boost::uniform_real<> dist(0, cumulative.back());
- boost::variate_generator<boost::mt19937&, boost::uniform_real<> > die(gen, dist);
- /*<< Find the position within the sequence and add 1
- (to make sure that the result is in the range [1,6]
- instead of [0,5])
+ /*<< Add 1 to make sure that the result is in the range [1,6]
+ instead of [0,5].
>>*/
- return (std::lower_bound(cumulative.begin(), cumulative.end(), die()) - cumulative.begin()) + 1;
+ return dist(gen) + 1;
}
//]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk