annotate DEPENDENCIES/generic/include/boost/random/normal_distribution.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /* boost random/normal_distribution.hpp header file
Chris@16 2 *
Chris@16 3 * Copyright Jens Maurer 2000-2001
Chris@16 4 * Copyright Steven Watanabe 2010-2011
Chris@16 5 * Distributed under the Boost Software License, Version 1.0. (See
Chris@16 6 * accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 *
Chris@16 9 * See http://www.boost.org for most recent version including documentation.
Chris@16 10 *
Chris@101 11 * $Id$
Chris@16 12 *
Chris@16 13 * Revision history
Chris@16 14 * 2001-02-18 moved to individual header files
Chris@16 15 */
Chris@16 16
Chris@16 17 #ifndef BOOST_RANDOM_NORMAL_DISTRIBUTION_HPP
Chris@16 18 #define BOOST_RANDOM_NORMAL_DISTRIBUTION_HPP
Chris@16 19
Chris@16 20 #include <boost/config/no_tr1/cmath.hpp>
Chris@16 21 #include <istream>
Chris@16 22 #include <iosfwd>
Chris@16 23 #include <boost/assert.hpp>
Chris@16 24 #include <boost/limits.hpp>
Chris@16 25 #include <boost/static_assert.hpp>
Chris@101 26 #include <boost/integer.hpp>
Chris@101 27 #include <boost/integer/integer_mask.hpp>
Chris@101 28 #include <boost/type_traits/is_integral.hpp>
Chris@101 29 #include <boost/type_traits/make_unsigned.hpp>
Chris@16 30 #include <boost/random/detail/config.hpp>
Chris@16 31 #include <boost/random/detail/operators.hpp>
Chris@101 32 #include <boost/random/detail/integer_log2.hpp>
Chris@16 33 #include <boost/random/uniform_01.hpp>
Chris@101 34 #include <boost/random/uniform_int_distribution.hpp>
Chris@101 35 #include <boost/random/exponential_distribution.hpp>
Chris@101 36 #include <boost/mpl/bool.hpp>
Chris@16 37
Chris@16 38 namespace boost {
Chris@16 39 namespace random {
Chris@16 40
Chris@101 41 namespace detail {
Chris@101 42
Chris@101 43 // tables for the ziggurat algorithm
Chris@101 44 template<class RealType>
Chris@101 45 struct normal_table {
Chris@101 46 static const RealType table_x[129];
Chris@101 47 static const RealType table_y[129];
Chris@101 48 };
Chris@101 49
Chris@101 50 template<class RealType>
Chris@101 51 const RealType normal_table<RealType>::table_x[129] = {
Chris@101 52 3.7130862467403632609, 3.4426198558966521214, 3.2230849845786185446, 3.0832288582142137009,
Chris@101 53 2.9786962526450169606, 2.8943440070186706210, 2.8231253505459664379, 2.7611693723841538514,
Chris@101 54 2.7061135731187223371, 2.6564064112581924999, 2.6109722484286132035, 2.5690336259216391328,
Chris@101 55 2.5300096723854666170, 2.4934545220919507609, 2.4590181774083500943, 2.4264206455302115930,
Chris@101 56 2.3954342780074673425, 2.3658713701139875435, 2.3375752413355307354, 2.3104136836950021558,
Chris@101 57 2.2842740596736568056, 2.2590595738653295251, 2.2346863955870569803, 2.2110814088747278106,
Chris@101 58 2.1881804320720206093, 2.1659267937448407377, 2.1442701823562613518, 2.1231657086697899595,
Chris@101 59 2.1025731351849988838, 2.0824562379877246441, 2.0627822745039633575, 2.0435215366506694976,
Chris@101 60 2.0246469733729338782, 2.0061338699589668403, 1.9879595741230607243, 1.9701032608497132242,
Chris@101 61 1.9525457295488889058, 1.9352692282919002011, 1.9182573008597320303, 1.9014946531003176140,
Chris@101 62 1.8849670357028692380, 1.8686611409895420085, 1.8525645117230870617, 1.8366654602533840447,
Chris@101 63 1.8209529965910050740, 1.8054167642140487420, 1.7900469825946189862, 1.7748343955807692457,
Chris@101 64 1.7597702248942318749, 1.7448461281083765085, 1.7300541605582435350, 1.7153867407081165482,
Chris@101 65 1.7008366185643009437, 1.6863968467734863258, 1.6720607540918522072, 1.6578219209482075462,
Chris@101 66 1.6436741568569826489, 1.6296114794646783962, 1.6156280950371329644, 1.6017183802152770587,
Chris@101 67 1.5878768648844007019, 1.5740982160167497219, 1.5603772223598406870, 1.5467087798535034608,
Chris@101 68 1.5330878776675560787, 1.5195095847593707806, 1.5059690368565502602, 1.4924614237746154081,
Chris@101 69 1.4789819769830978546, 1.4655259573357946276, 1.4520886428822164926, 1.4386653166774613138,
Chris@101 70 1.4252512545068615734, 1.4118417124397602509, 1.3984319141236063517, 1.3850170377251486449,
Chris@101 71 1.3715922024197322698, 1.3581524543224228739, 1.3446927517457130432, 1.3312079496576765017,
Chris@101 72 1.3176927832013429910, 1.3041418501204215390, 1.2905495919178731508, 1.2769102735516997175,
Chris@101 73 1.2632179614460282310, 1.2494664995643337480, 1.2356494832544811749, 1.2217602305309625678,
Chris@101 74 1.2077917504067576028, 1.1937367078237721994, 1.1795873846544607035, 1.1653356361550469083,
Chris@101 75 1.1509728421389760651, 1.1364898520030755352, 1.1218769225722540661, 1.1071236475235353980,
Chris@101 76 1.0922188768965537614, 1.0771506248819376573, 1.0619059636836193998, 1.0464709007525802629,
Chris@101 77 1.0308302360564555907, 1.0149673952392994716, 0.99886423348064351303, 0.98250080350276038481,
Chris@101 78 0.96585507938813059489, 0.94890262549791195381, 0.93161619660135381056, 0.91396525100880177644,
Chris@101 79 0.89591535256623852894, 0.87742742909771569142, 0.85845684317805086354, 0.83895221428120745572,
Chris@101 80 0.81885390668331772331, 0.79809206062627480454, 0.77658398787614838598, 0.75423066443451007146,
Chris@101 81 0.73091191062188128150, 0.70647961131360803456, 0.68074791864590421664, 0.65347863871504238702,
Chris@101 82 0.62435859730908822111, 0.59296294244197797913, 0.55869217837551797140, 0.52065603872514491759,
Chris@101 83 0.47743783725378787681, 0.42654798630330512490, 0.36287143102841830424, 0.27232086470466385065,
Chris@101 84 0
Chris@101 85 };
Chris@101 86
Chris@101 87 template<class RealType>
Chris@101 88 const RealType normal_table<RealType>::table_y[129] = {
Chris@101 89 0, 0.0026696290839025035092, 0.0055489952208164705392, 0.0086244844129304709682,
Chris@101 90 0.011839478657982313715, 0.015167298010672042468, 0.018592102737165812650, 0.022103304616111592615,
Chris@101 91 0.025693291936149616572, 0.029356317440253829618, 0.033087886146505155566, 0.036884388786968774128,
Chris@101 92 0.040742868074790604632, 0.044660862200872429800, 0.048636295860284051878, 0.052667401903503169793,
Chris@101 93 0.056752663481538584188, 0.060890770348566375972, 0.065080585213631873753, 0.069321117394180252601,
Chris@101 94 0.073611501884754893389, 0.077950982514654714188, 0.082338898242957408243, 0.086774671895542968998,
Chris@101 95 0.091257800827634710201, 0.09578784912257815216, 0.10036444102954554013, 0.10498725541035453978,
Chris@101 96 0.10965602101581776100, 0.11437051244988827452, 0.11913054670871858767, 0.12393598020398174246,
Chris@101 97 0.12878670619710396109, 0.13368265258464764118, 0.13862377998585103702, 0.14361008009193299469,
Chris@101 98 0.14864157424369696566, 0.15371831220958657066, 0.15884037114093507813, 0.16400785468492774791,
Chris@101 99 0.16922089223892475176, 0.17447963833240232295, 0.17978427212496211424, 0.18513499701071343216,
Chris@101 100 0.19053204032091372112, 0.19597565311811041399, 0.20146611007620324118, 0.20700370944187380064,
Chris@101 101 0.21258877307373610060, 0.21822164655637059599, 0.22390269938713388747, 0.22963232523430270355,
Chris@101 102 0.23541094226572765600, 0.24123899354775131610, 0.24711694751469673582, 0.25304529850976585934,
Chris@101 103 0.25902456739871074263, 0.26505530225816194029, 0.27113807914102527343, 0.27727350292189771153,
Chris@101 104 0.28346220822601251779, 0.28970486044581049771, 0.29600215684985583659, 0.30235482778947976274,
Chris@101 105 0.30876363800925192282, 0.31522938806815752222, 0.32175291587920862031, 0.32833509837615239609,
Chris@101 106 0.33497685331697116147, 0.34167914123501368412, 0.34844296754987246935, 0.35526938485154714435,
Chris@101 107 0.36215949537303321162, 0.36911445366827513952, 0.37613546951445442947, 0.38322381105988364587,
Chris@101 108 0.39038080824138948916, 0.39760785649804255208, 0.40490642081148835099, 0.41227804010702462062,
Chris@101 109 0.41972433205403823467, 0.42724699830956239880, 0.43484783025466189638, 0.44252871528024661483,
Chris@101 110 0.45029164368692696086, 0.45813871627287196483, 0.46607215269457097924, 0.47409430069824960453,
Chris@101 111 0.48220764633483869062, 0.49041482528932163741, 0.49871863547658432422, 0.50712205108130458951,
Chris@101 112 0.51562823824987205196, 0.52424057267899279809, 0.53296265938998758838, 0.54179835503172412311,
Chris@101 113 0.55075179312105527738, 0.55982741271069481791, 0.56902999107472161225, 0.57836468112670231279,
Chris@101 114 0.58783705444182052571, 0.59745315095181228217, 0.60721953663260488551, 0.61714337082656248870,
Chris@101 115 0.62723248525781456578, 0.63749547734314487428, 0.64794182111855080873, 0.65858200005865368016,
Chris@101 116 0.66942766735770616891, 0.68049184100641433355, 0.69178914344603585279, 0.70333609902581741633,
Chris@101 117 0.71515150742047704368, 0.72725691835450587793, 0.73967724368333814856, 0.75244155918570380145,
Chris@101 118 0.76558417390923599480, 0.77914608594170316563, 0.79317701178385921053, 0.80773829469612111340,
Chris@101 119 0.82290721139526200050, 0.83878360531064722379, 0.85550060788506428418, 0.87324304892685358879,
Chris@101 120 0.89228165080230272301, 0.91304364799203805999, 0.93628268170837107547, 0.96359969315576759960,
Chris@101 121 1
Chris@101 122 };
Chris@101 123
Chris@101 124 template<class Engine>
Chris@101 125 inline typename boost::make_unsigned<typename Engine::result_type>::type
Chris@101 126 generate_one_digit(Engine& eng, std::size_t bits)
Chris@101 127 {
Chris@101 128 typedef typename Engine::result_type base_result;
Chris@101 129 typedef typename boost::make_unsigned<base_result>::type base_unsigned;
Chris@101 130
Chris@101 131 base_unsigned range =
Chris@101 132 detail::subtract<base_result>()((eng.max)(), (eng.min)());
Chris@101 133 base_unsigned y0_mask = (base_unsigned(2) << (bits - 1)) - 1;
Chris@101 134 base_unsigned y0 = (range + 1) & ~y0_mask;
Chris@101 135 base_unsigned u;
Chris@101 136 do {
Chris@101 137 u = detail::subtract<base_result>()(eng(), (eng.min)());
Chris@101 138 } while(y0 != 0 && u > base_unsigned(y0 - 1));
Chris@101 139 return u & y0_mask;
Chris@101 140 }
Chris@101 141
Chris@101 142 template<class RealType, std::size_t w, class Engine>
Chris@101 143 std::pair<RealType, int> generate_int_float_pair(Engine& eng, boost::mpl::true_)
Chris@101 144 {
Chris@101 145 typedef typename Engine::result_type base_result;
Chris@101 146 typedef typename boost::make_unsigned<base_result>::type base_unsigned;
Chris@101 147
Chris@101 148 base_unsigned range =
Chris@101 149 detail::subtract<base_result>()((eng.max)(), (eng.min)());
Chris@101 150
Chris@101 151 std::size_t m =
Chris@101 152 (range == (std::numeric_limits<base_unsigned>::max)()) ?
Chris@101 153 std::numeric_limits<base_unsigned>::digits :
Chris@101 154 detail::integer_log2(range + 1);
Chris@101 155
Chris@101 156 int bucket = 0;
Chris@101 157 // process as many full digits as possible into the int part
Chris@101 158 for(std::size_t i = 0; i < w/m; ++i) {
Chris@101 159 base_unsigned u = generate_one_digit(eng, m);
Chris@101 160 bucket = (bucket << m) | u;
Chris@101 161 }
Chris@101 162 RealType r;
Chris@101 163
Chris@101 164 const std::size_t digits = std::numeric_limits<RealType>::digits;
Chris@101 165 {
Chris@101 166 base_unsigned u = generate_one_digit(eng, m);
Chris@101 167 base_unsigned mask = (base_unsigned(1) << (w%m)) - 1;
Chris@101 168 bucket = (bucket << (w%m)) | (mask & u);
Chris@101 169 const RealType mult = RealType(1)/RealType(base_unsigned(1) << (m - w%m));
Chris@101 170 // zero out unused bits
Chris@101 171 if (m - w%m > digits) {
Chris@101 172 u &= ~(base_unsigned(1) << (m - digits));
Chris@101 173 }
Chris@101 174 r = RealType(u >> (w%m)) * mult;
Chris@101 175 }
Chris@101 176 for(std::size_t i = m - w%m; i + m < digits; ++i) {
Chris@101 177 base_unsigned u = generate_one_digit(eng, m);
Chris@101 178 r += u;
Chris@101 179 r *= RealType(0.5)/RealType(base_unsigned(1) << (m - 1));
Chris@101 180 }
Chris@101 181 if (m - w%m < digits)
Chris@101 182 {
Chris@101 183 const std::size_t remaining = (digits - m + w%m) % m;
Chris@101 184 base_unsigned u = generate_one_digit(eng, m);
Chris@101 185 r += u & ((base_unsigned(2) << (remaining - 1)) - 1);
Chris@101 186 const RealType mult = RealType(0.5)/RealType(base_unsigned(1) << (remaining - 1));
Chris@101 187 r *= mult;
Chris@101 188 }
Chris@101 189 return std::make_pair(r, bucket);
Chris@101 190 }
Chris@101 191
Chris@101 192 template<class RealType, std::size_t w, class Engine>
Chris@101 193 inline std::pair<RealType, int> generate_int_float_pair(Engine& eng, boost::mpl::false_)
Chris@101 194 {
Chris@101 195 int bucket = uniform_int_distribution<>(0, (1 << w) - 1)(eng);
Chris@101 196 RealType r = uniform_01<RealType>()(eng);
Chris@101 197 return std::make_pair(r, bucket);
Chris@101 198 }
Chris@101 199
Chris@101 200 template<class RealType, std::size_t w, class Engine>
Chris@101 201 inline std::pair<RealType, int> generate_int_float_pair(Engine& eng)
Chris@101 202 {
Chris@101 203 typedef typename Engine::result_type base_result;
Chris@101 204 return generate_int_float_pair<RealType, w>(eng,
Chris@101 205 boost::is_integral<base_result>());
Chris@101 206 }
Chris@101 207
Chris@101 208 template<class RealType = double>
Chris@101 209 struct unit_normal_distribution
Chris@101 210 {
Chris@101 211 template<class Engine>
Chris@101 212 RealType operator()(Engine& eng) {
Chris@101 213 const double * const table_x = normal_table<double>::table_x;
Chris@101 214 const double * const table_y = normal_table<double>::table_y;
Chris@101 215 for(;;) {
Chris@101 216 std::pair<RealType, int> vals = generate_int_float_pair<RealType, 8>(eng);
Chris@101 217 int i = vals.second;
Chris@101 218 int sign = (i & 1) * 2 - 1;
Chris@101 219 i = i >> 1;
Chris@101 220 RealType x = vals.first * RealType(table_x[i]);
Chris@101 221 if(x < table_x[i + 1]) return x * sign;
Chris@101 222 if(i == 0) return generate_tail(eng) * sign;
Chris@101 223 RealType y = RealType(table_y[i]) + uniform_01<RealType>()(eng) * RealType(table_y[i + 1] - table_y[i]);
Chris@101 224 if (y < f(x)) return x * sign;
Chris@101 225 }
Chris@101 226 }
Chris@101 227 static RealType f(RealType x) {
Chris@101 228 using std::exp;
Chris@101 229 return exp(-x*x/2);
Chris@101 230 }
Chris@101 231 template<class Engine>
Chris@101 232 RealType generate_tail(Engine& eng) {
Chris@101 233 boost::random::exponential_distribution<RealType> exponential;
Chris@101 234 const RealType tail_start = RealType(normal_table<double>::table_x[1]);
Chris@101 235 for(;;) {
Chris@101 236 RealType x = exponential(eng)/tail_start;
Chris@101 237 RealType y = exponential(eng);
Chris@101 238 if(2*y > x*x) return x + tail_start;
Chris@101 239 }
Chris@101 240 }
Chris@101 241 };
Chris@101 242
Chris@101 243 }
Chris@101 244
Chris@16 245 // deterministic Box-Muller method, uses trigonometric functions
Chris@16 246
Chris@16 247 /**
Chris@16 248 * Instantiations of class template normal_distribution model a
Chris@16 249 * \random_distribution. Such a distribution produces random numbers
Chris@16 250 * @c x distributed with probability density function
Chris@16 251 * \f$\displaystyle p(x) =
Chris@101 252 * \frac{1}{\sqrt{2\pi}\sigma} e^{-\frac{(x-\mu)^2}{2\sigma^2}}
Chris@16 253 * \f$,
Chris@16 254 * where mean and sigma are the parameters of the distribution.
Chris@16 255 */
Chris@16 256 template<class RealType = double>
Chris@16 257 class normal_distribution
Chris@16 258 {
Chris@16 259 public:
Chris@16 260 typedef RealType input_type;
Chris@16 261 typedef RealType result_type;
Chris@16 262
Chris@16 263 class param_type {
Chris@16 264 public:
Chris@16 265 typedef normal_distribution distribution_type;
Chris@16 266
Chris@16 267 /**
Chris@16 268 * Constructs a @c param_type with a given mean and
Chris@16 269 * standard deviation.
Chris@16 270 *
Chris@16 271 * Requires: sigma >= 0
Chris@16 272 */
Chris@16 273 explicit param_type(RealType mean_arg = RealType(0.0),
Chris@16 274 RealType sigma_arg = RealType(1.0))
Chris@16 275 : _mean(mean_arg),
Chris@16 276 _sigma(sigma_arg)
Chris@16 277 {}
Chris@16 278
Chris@16 279 /** Returns the mean of the distribution. */
Chris@16 280 RealType mean() const { return _mean; }
Chris@16 281
Chris@16 282 /** Returns the standand deviation of the distribution. */
Chris@16 283 RealType sigma() const { return _sigma; }
Chris@16 284
Chris@16 285 /** Writes a @c param_type to a @c std::ostream. */
Chris@16 286 BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, param_type, parm)
Chris@16 287 { os << parm._mean << " " << parm._sigma ; return os; }
Chris@16 288
Chris@16 289 /** Reads a @c param_type from a @c std::istream. */
Chris@16 290 BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
Chris@16 291 { is >> parm._mean >> std::ws >> parm._sigma; return is; }
Chris@16 292
Chris@16 293 /** Returns true if the two sets of parameters are the same. */
Chris@16 294 BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(param_type, lhs, rhs)
Chris@16 295 { return lhs._mean == rhs._mean && lhs._sigma == rhs._sigma; }
Chris@16 296
Chris@16 297 /** Returns true if the two sets of parameters are the different. */
Chris@16 298 BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
Chris@16 299
Chris@16 300 private:
Chris@16 301 RealType _mean;
Chris@16 302 RealType _sigma;
Chris@16 303 };
Chris@16 304
Chris@16 305 /**
Chris@16 306 * Constructs a @c normal_distribution object. @c mean and @c sigma are
Chris@16 307 * the parameters for the distribution.
Chris@16 308 *
Chris@16 309 * Requires: sigma >= 0
Chris@16 310 */
Chris@16 311 explicit normal_distribution(const RealType& mean_arg = RealType(0.0),
Chris@16 312 const RealType& sigma_arg = RealType(1.0))
Chris@101 313 : _mean(mean_arg), _sigma(sigma_arg)
Chris@16 314 {
Chris@16 315 BOOST_ASSERT(_sigma >= RealType(0));
Chris@16 316 }
Chris@16 317
Chris@16 318 /**
Chris@16 319 * Constructs a @c normal_distribution object from its parameters.
Chris@16 320 */
Chris@16 321 explicit normal_distribution(const param_type& parm)
Chris@101 322 : _mean(parm.mean()), _sigma(parm.sigma())
Chris@16 323 {}
Chris@16 324
Chris@16 325 /** Returns the mean of the distribution. */
Chris@16 326 RealType mean() const { return _mean; }
Chris@16 327 /** Returns the standard deviation of the distribution. */
Chris@16 328 RealType sigma() const { return _sigma; }
Chris@16 329
Chris@16 330 /** Returns the smallest value that the distribution can produce. */
Chris@16 331 RealType min BOOST_PREVENT_MACRO_SUBSTITUTION () const
Chris@16 332 { return -std::numeric_limits<RealType>::infinity(); }
Chris@16 333 /** Returns the largest value that the distribution can produce. */
Chris@16 334 RealType max BOOST_PREVENT_MACRO_SUBSTITUTION () const
Chris@16 335 { return std::numeric_limits<RealType>::infinity(); }
Chris@16 336
Chris@16 337 /** Returns the parameters of the distribution. */
Chris@16 338 param_type param() const { return param_type(_mean, _sigma); }
Chris@16 339 /** Sets the parameters of the distribution. */
Chris@16 340 void param(const param_type& parm)
Chris@16 341 {
Chris@16 342 _mean = parm.mean();
Chris@16 343 _sigma = parm.sigma();
Chris@16 344 }
Chris@16 345
Chris@16 346 /**
Chris@16 347 * Effects: Subsequent uses of the distribution do not depend
Chris@16 348 * on values produced by any engine prior to invoking reset.
Chris@16 349 */
Chris@101 350 void reset() { }
Chris@16 351
Chris@16 352 /** Returns a normal variate. */
Chris@16 353 template<class Engine>
Chris@16 354 result_type operator()(Engine& eng)
Chris@16 355 {
Chris@101 356 detail::unit_normal_distribution<RealType> impl;
Chris@101 357 return impl(eng) * _sigma + _mean;
Chris@16 358 }
Chris@16 359
Chris@16 360 /** Returns a normal variate with parameters specified by @c param. */
Chris@16 361 template<class URNG>
Chris@16 362 result_type operator()(URNG& urng, const param_type& parm)
Chris@16 363 {
Chris@16 364 return normal_distribution(parm)(urng);
Chris@16 365 }
Chris@16 366
Chris@16 367 /** Writes a @c normal_distribution to a @c std::ostream. */
Chris@16 368 BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, normal_distribution, nd)
Chris@16 369 {
Chris@101 370 os << nd._mean << " " << nd._sigma;
Chris@16 371 return os;
Chris@16 372 }
Chris@16 373
Chris@16 374 /** Reads a @c normal_distribution from a @c std::istream. */
Chris@16 375 BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, normal_distribution, nd)
Chris@16 376 {
Chris@101 377 is >> std::ws >> nd._mean >> std::ws >> nd._sigma;
Chris@16 378 return is;
Chris@16 379 }
Chris@16 380
Chris@16 381 /**
Chris@16 382 * Returns true if the two instances of @c normal_distribution will
Chris@16 383 * return identical sequences of values given equal generators.
Chris@16 384 */
Chris@16 385 BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(normal_distribution, lhs, rhs)
Chris@16 386 {
Chris@101 387 return lhs._mean == rhs._mean && lhs._sigma == rhs._sigma;
Chris@16 388 }
Chris@16 389
Chris@16 390 /**
Chris@16 391 * Returns true if the two instances of @c normal_distribution will
Chris@16 392 * return different sequences of values given equal generators.
Chris@16 393 */
Chris@16 394 BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(normal_distribution)
Chris@16 395
Chris@16 396 private:
Chris@16 397 RealType _mean, _sigma;
Chris@16 398
Chris@16 399 };
Chris@16 400
Chris@16 401 } // namespace random
Chris@16 402
Chris@16 403 using random::normal_distribution;
Chris@16 404
Chris@16 405 } // namespace boost
Chris@16 406
Chris@16 407 #endif // BOOST_RANDOM_NORMAL_DISTRIBUTION_HPP