Warning, /include/c++/v1/random is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP_RANDOM
0011 #define _LIBCPP_RANDOM
0012
0013 /*
0014 random synopsis
0015
0016 #include <initializer_list>
0017
0018 namespace std
0019 {
0020 // [rand.req.urng], uniform random bit generator requirements
0021 template<class G>
0022 concept uniform_random_bit_generator = see below; // C++20
0023
0024 // Engines
0025
0026 template <class UIntType, UIntType a, UIntType c, UIntType m>
0027 class linear_congruential_engine
0028 {
0029 public:
0030 // types
0031 typedef UIntType result_type;
0032
0033 // engine characteristics
0034 static constexpr result_type multiplier = a;
0035 static constexpr result_type increment = c;
0036 static constexpr result_type modulus = m;
0037 static constexpr result_type min() { return c == 0u ? 1u: 0u;}
0038 static constexpr result_type max() { return m - 1u;}
0039 static constexpr result_type default_seed = 1u;
0040
0041 // constructors and seeding functions
0042 explicit linear_congruential_engine(result_type s = default_seed); // before C++20
0043 linear_congruential_engine() : linear_congruential_engine(default_seed) {} // C++20
0044 explicit linear_congruential_engine(result_type s); // C++20
0045 template<class Sseq> explicit linear_congruential_engine(Sseq& q);
0046 void seed(result_type s = default_seed);
0047 template<class Sseq> void seed(Sseq& q);
0048
0049 // generating functions
0050 result_type operator()();
0051 void discard(unsigned long long z);
0052 };
0053
0054 template <class UIntType, UIntType a, UIntType c, UIntType m>
0055 bool
0056 operator==(const linear_congruential_engine<UIntType, a, c, m>& x,
0057 const linear_congruential_engine<UIntType, a, c, m>& y);
0058
0059 template <class UIntType, UIntType a, UIntType c, UIntType m>
0060 bool
0061 operator!=(const linear_congruential_engine<UIntType, a, c, m>& x,
0062 const linear_congruential_engine<UIntType, a, c, m>& y);
0063
0064 template <class charT, class traits,
0065 class UIntType, UIntType a, UIntType c, UIntType m>
0066 basic_ostream<charT, traits>&
0067 operator<<(basic_ostream<charT, traits>& os,
0068 const linear_congruential_engine<UIntType, a, c, m>& x);
0069
0070 template <class charT, class traits,
0071 class UIntType, UIntType a, UIntType c, UIntType m>
0072 basic_istream<charT, traits>&
0073 operator>>(basic_istream<charT, traits>& is,
0074 linear_congruential_engine<UIntType, a, c, m>& x);
0075
0076 template <class UIntType, size_t w, size_t n, size_t m, size_t r,
0077 UIntType a, size_t u, UIntType d, size_t s,
0078 UIntType b, size_t t, UIntType c, size_t l, UIntType f>
0079 class mersenne_twister_engine
0080 {
0081 public:
0082 // types
0083 typedef UIntType result_type;
0084
0085 // engine characteristics
0086 static constexpr size_t word_size = w;
0087 static constexpr size_t state_size = n;
0088 static constexpr size_t shift_size = m;
0089 static constexpr size_t mask_bits = r;
0090 static constexpr result_type xor_mask = a;
0091 static constexpr size_t tempering_u = u;
0092 static constexpr result_type tempering_d = d;
0093 static constexpr size_t tempering_s = s;
0094 static constexpr result_type tempering_b = b;
0095 static constexpr size_t tempering_t = t;
0096 static constexpr result_type tempering_c = c;
0097 static constexpr size_t tempering_l = l;
0098 static constexpr result_type initialization_multiplier = f;
0099 static constexpr result_type min () { return 0; }
0100 static constexpr result_type max() { return 2^w - 1; }
0101 static constexpr result_type default_seed = 5489u;
0102
0103 // constructors and seeding functions
0104 explicit mersenne_twister_engine(result_type s = default_seed); // before C++20
0105 mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} // C++20
0106 explicit mersenne_twister_engine(result_type s); // C++20
0107 template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
0108 void seed(result_type value = default_seed);
0109 template<class Sseq> void seed(Sseq& q);
0110
0111 // generating functions
0112 result_type operator()();
0113 void discard(unsigned long long z);
0114 };
0115
0116 template <class UIntType, size_t w, size_t n, size_t m, size_t r,
0117 UIntType a, size_t u, UIntType d, size_t s,
0118 UIntType b, size_t t, UIntType c, size_t l, UIntType f>
0119 bool
0120 operator==(
0121 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
0122 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
0123
0124 template <class UIntType, size_t w, size_t n, size_t m, size_t r,
0125 UIntType a, size_t u, UIntType d, size_t s,
0126 UIntType b, size_t t, UIntType c, size_t l, UIntType f>
0127 bool
0128 operator!=(
0129 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
0130 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
0131
0132 template <class charT, class traits,
0133 class UIntType, size_t w, size_t n, size_t m, size_t r,
0134 UIntType a, size_t u, UIntType d, size_t s,
0135 UIntType b, size_t t, UIntType c, size_t l, UIntType f>
0136 basic_ostream<charT, traits>&
0137 operator<<(basic_ostream<charT, traits>& os,
0138 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
0139
0140 template <class charT, class traits,
0141 class UIntType, size_t w, size_t n, size_t m, size_t r,
0142 UIntType a, size_t u, UIntType d, size_t s,
0143 UIntType b, size_t t, UIntType c, size_t l, UIntType f>
0144 basic_istream<charT, traits>&
0145 operator>>(basic_istream<charT, traits>& is,
0146 mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
0147
0148 template<class UIntType, size_t w, size_t s, size_t r>
0149 class subtract_with_carry_engine
0150 {
0151 public:
0152 // types
0153 typedef UIntType result_type;
0154
0155 // engine characteristics
0156 static constexpr size_t word_size = w;
0157 static constexpr size_t short_lag = s;
0158 static constexpr size_t long_lag = r;
0159 static constexpr result_type min() { return 0; }
0160 static constexpr result_type max() { return m-1; }
0161 static constexpr result_type default_seed = 19780503u;
0162
0163 // constructors and seeding functions
0164 explicit subtract_with_carry_engine(result_type value = default_seed); // before C++20
0165 subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} // C++20
0166 explicit subtract_with_carry_engine(result_type value); // C++20
0167 template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
0168 void seed(result_type value = default_seed);
0169 template<class Sseq> void seed(Sseq& q);
0170
0171 // generating functions
0172 result_type operator()();
0173 void discard(unsigned long long z);
0174 };
0175
0176 template<class UIntType, size_t w, size_t s, size_t r>
0177 bool
0178 operator==(
0179 const subtract_with_carry_engine<UIntType, w, s, r>& x,
0180 const subtract_with_carry_engine<UIntType, w, s, r>& y);
0181
0182 template<class UIntType, size_t w, size_t s, size_t r>
0183 bool
0184 operator!=(
0185 const subtract_with_carry_engine<UIntType, w, s, r>& x,
0186 const subtract_with_carry_engine<UIntType, w, s, r>& y);
0187
0188 template <class charT, class traits,
0189 class UIntType, size_t w, size_t s, size_t r>
0190 basic_ostream<charT, traits>&
0191 operator<<(basic_ostream<charT, traits>& os,
0192 const subtract_with_carry_engine<UIntType, w, s, r>& x);
0193
0194 template <class charT, class traits,
0195 class UIntType, size_t w, size_t s, size_t r>
0196 basic_istream<charT, traits>&
0197 operator>>(basic_istream<charT, traits>& is,
0198 subtract_with_carry_engine<UIntType, w, s, r>& x);
0199
0200 template<class Engine, size_t p, size_t r>
0201 class discard_block_engine
0202 {
0203 public:
0204 // types
0205 typedef typename Engine::result_type result_type;
0206
0207 // engine characteristics
0208 static constexpr size_t block_size = p;
0209 static constexpr size_t used_block = r;
0210 static constexpr result_type min() { return Engine::min(); }
0211 static constexpr result_type max() { return Engine::max(); }
0212
0213 // constructors and seeding functions
0214 discard_block_engine();
0215 explicit discard_block_engine(const Engine& e);
0216 explicit discard_block_engine(Engine&& e);
0217 explicit discard_block_engine(result_type s);
0218 template<class Sseq> explicit discard_block_engine(Sseq& q);
0219 void seed();
0220 void seed(result_type s);
0221 template<class Sseq> void seed(Sseq& q);
0222
0223 // generating functions
0224 result_type operator()();
0225 void discard(unsigned long long z);
0226
0227 // property functions
0228 const Engine& base() const noexcept;
0229 };
0230
0231 template<class Engine, size_t p, size_t r>
0232 bool
0233 operator==(
0234 const discard_block_engine<Engine, p, r>& x,
0235 const discard_block_engine<Engine, p, r>& y);
0236
0237 template<class Engine, size_t p, size_t r>
0238 bool
0239 operator!=(
0240 const discard_block_engine<Engine, p, r>& x,
0241 const discard_block_engine<Engine, p, r>& y);
0242
0243 template <class charT, class traits,
0244 class Engine, size_t p, size_t r>
0245 basic_ostream<charT, traits>&
0246 operator<<(basic_ostream<charT, traits>& os,
0247 const discard_block_engine<Engine, p, r>& x);
0248
0249 template <class charT, class traits,
0250 class Engine, size_t p, size_t r>
0251 basic_istream<charT, traits>&
0252 operator>>(basic_istream<charT, traits>& is,
0253 discard_block_engine<Engine, p, r>& x);
0254
0255 template<class Engine, size_t w, class UIntType>
0256 class independent_bits_engine
0257 {
0258 public:
0259 // types
0260 typedef UIntType result_type;
0261
0262 // engine characteristics
0263 static constexpr result_type min() { return 0; }
0264 static constexpr result_type max() { return 2^w - 1; }
0265
0266 // constructors and seeding functions
0267 independent_bits_engine();
0268 explicit independent_bits_engine(const Engine& e);
0269 explicit independent_bits_engine(Engine&& e);
0270 explicit independent_bits_engine(result_type s);
0271 template<class Sseq> explicit independent_bits_engine(Sseq& q);
0272 void seed();
0273 void seed(result_type s);
0274 template<class Sseq> void seed(Sseq& q);
0275
0276 // generating functions
0277 result_type operator()(); void discard(unsigned long long z);
0278
0279 // property functions
0280 const Engine& base() const noexcept;
0281 };
0282
0283 template<class Engine, size_t w, class UIntType>
0284 bool
0285 operator==(
0286 const independent_bits_engine<Engine, w, UIntType>& x,
0287 const independent_bits_engine<Engine, w, UIntType>& y);
0288
0289 template<class Engine, size_t w, class UIntType>
0290 bool
0291 operator!=(
0292 const independent_bits_engine<Engine, w, UIntType>& x,
0293 const independent_bits_engine<Engine, w, UIntType>& y);
0294
0295 template <class charT, class traits,
0296 class Engine, size_t w, class UIntType>
0297 basic_ostream<charT, traits>&
0298 operator<<(basic_ostream<charT, traits>& os,
0299 const independent_bits_engine<Engine, w, UIntType>& x);
0300
0301 template <class charT, class traits,
0302 class Engine, size_t w, class UIntType>
0303 basic_istream<charT, traits>&
0304 operator>>(basic_istream<charT, traits>& is,
0305 independent_bits_engine<Engine, w, UIntType>& x);
0306
0307 template<class Engine, size_t k>
0308 class shuffle_order_engine
0309 {
0310 public:
0311 // types
0312 typedef typename Engine::result_type result_type;
0313
0314 // engine characteristics
0315 static constexpr size_t table_size = k;
0316 static constexpr result_type min() { return Engine::min; }
0317 static constexpr result_type max() { return Engine::max; }
0318
0319 // constructors and seeding functions
0320 shuffle_order_engine();
0321 explicit shuffle_order_engine(const Engine& e);
0322 explicit shuffle_order_engine(Engine&& e);
0323 explicit shuffle_order_engine(result_type s);
0324 template<class Sseq> explicit shuffle_order_engine(Sseq& q);
0325 void seed();
0326 void seed(result_type s);
0327 template<class Sseq> void seed(Sseq& q);
0328
0329 // generating functions
0330 result_type operator()();
0331 void discard(unsigned long long z);
0332
0333 // property functions
0334 const Engine& base() const noexcept;
0335 };
0336
0337 template<class Engine, size_t k>
0338 bool
0339 operator==(
0340 const shuffle_order_engine<Engine, k>& x,
0341 const shuffle_order_engine<Engine, k>& y);
0342
0343 template<class Engine, size_t k>
0344 bool
0345 operator!=(
0346 const shuffle_order_engine<Engine, k>& x,
0347 const shuffle_order_engine<Engine, k>& y);
0348
0349 template <class charT, class traits,
0350 class Engine, size_t k>
0351 basic_ostream<charT, traits>&
0352 operator<<(basic_ostream<charT, traits>& os,
0353 const shuffle_order_engine<Engine, k>& x);
0354
0355 template <class charT, class traits,
0356 class Engine, size_t k>
0357 basic_istream<charT, traits>&
0358 operator>>(basic_istream<charT, traits>& is,
0359 shuffle_order_engine<Engine, k>& x);
0360
0361 typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
0362 minstd_rand0;
0363 typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
0364 minstd_rand;
0365 typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
0366 0x9908b0df,
0367 11, 0xffffffff,
0368 7, 0x9d2c5680,
0369 15, 0xefc60000,
0370 18, 1812433253> mt19937;
0371 typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
0372 0xb5026f5aa96619e9,
0373 29, 0x5555555555555555,
0374 17, 0x71d67fffeda60000,
0375 37, 0xfff7eee000000000,
0376 43, 6364136223846793005> mt19937_64;
0377 typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base;
0378 typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base;
0379 typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
0380 typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
0381 typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
0382 typedef minstd_rand default_random_engine;
0383
0384 // Generators
0385
0386 class random_device
0387 {
0388 public:
0389 // types
0390 typedef unsigned int result_type;
0391
0392 // generator characteristics
0393 static constexpr result_type min() { return numeric_limits<result_type>::min(); }
0394 static constexpr result_type max() { return numeric_limits<result_type>::max(); }
0395
0396 // constructors
0397 explicit random_device(const string& token = implementation-defined); // before C++20
0398 random_device() : random_device(implementation-defined) {} // C++20
0399 explicit random_device(const string& token); // C++20
0400
0401 // generating functions
0402 result_type operator()();
0403
0404 // property functions
0405 double entropy() const noexcept;
0406
0407 // no copy functions
0408 random_device(const random_device& ) = delete;
0409 void operator=(const random_device& ) = delete;
0410 };
0411
0412 // Utilities
0413
0414 class seed_seq
0415 {
0416 public:
0417 // types
0418 typedef uint_least32_t result_type;
0419
0420 // constructors
0421 seed_seq();
0422 template<class T>
0423 seed_seq(initializer_list<T> il);
0424 template<class InputIterator>
0425 seed_seq(InputIterator begin, InputIterator end);
0426
0427 // generating functions
0428 template<class RandomAccessIterator>
0429 void generate(RandomAccessIterator begin, RandomAccessIterator end);
0430
0431 // property functions
0432 size_t size() const;
0433 template<class OutputIterator>
0434 void param(OutputIterator dest) const;
0435
0436 // no copy functions
0437 seed_seq(const seed_seq&) = delete;
0438 void operator=(const seed_seq& ) = delete;
0439 };
0440
0441 template<class RealType, size_t bits, class URNG>
0442 RealType generate_canonical(URNG& g);
0443
0444 // Distributions
0445
0446 template<class IntType = int>
0447 class uniform_int_distribution
0448 {
0449 public:
0450 // types
0451 typedef IntType result_type;
0452
0453 class param_type
0454 {
0455 public:
0456 typedef uniform_int_distribution distribution_type;
0457
0458 explicit param_type(IntType a = 0,
0459 IntType b = numeric_limits<IntType>::max());
0460
0461 result_type a() const;
0462 result_type b() const;
0463
0464 friend bool operator==(const param_type& x, const param_type& y);
0465 friend bool operator!=(const param_type& x, const param_type& y);
0466 };
0467
0468 // constructors and reset functions
0469 explicit uniform_int_distribution(IntType a = 0,
0470 IntType b = numeric_limits<IntType>::max()); // before C++20
0471 uniform_int_distribution() : uniform_int_distribution(0) {} // C++20
0472 explicit uniform_int_distribution(IntType a,
0473 IntType b = numeric_limits<IntType>::max()); // C++20
0474 explicit uniform_int_distribution(const param_type& parm);
0475 void reset();
0476
0477 // generating functions
0478 template<class URNG> result_type operator()(URNG& g);
0479 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0480
0481 // property functions
0482 result_type a() const;
0483 result_type b() const;
0484
0485 param_type param() const;
0486 void param(const param_type& parm);
0487
0488 result_type min() const;
0489 result_type max() const;
0490
0491 friend bool operator==(const uniform_int_distribution& x,
0492 const uniform_int_distribution& y);
0493 friend bool operator!=(const uniform_int_distribution& x,
0494 const uniform_int_distribution& y);
0495
0496 template <class charT, class traits>
0497 friend
0498 basic_ostream<charT, traits>&
0499 operator<<(basic_ostream<charT, traits>& os,
0500 const uniform_int_distribution& x);
0501
0502 template <class charT, class traits>
0503 friend
0504 basic_istream<charT, traits>&
0505 operator>>(basic_istream<charT, traits>& is,
0506 uniform_int_distribution& x);
0507 };
0508
0509 template<class RealType = double>
0510 class uniform_real_distribution
0511 {
0512 public:
0513 // types
0514 typedef RealType result_type;
0515
0516 class param_type
0517 {
0518 public:
0519 typedef uniform_real_distribution distribution_type;
0520
0521 explicit param_type(RealType a = 0,
0522 RealType b = 1);
0523
0524 result_type a() const;
0525 result_type b() const;
0526
0527 friend bool operator==(const param_type& x, const param_type& y);
0528 friend bool operator!=(const param_type& x, const param_type& y);
0529 };
0530
0531 // constructors and reset functions
0532 explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
0533 uniform_real_distribution() : uniform_real_distribution(0.0) {} // C++20
0534 explicit uniform_real_distribution(RealType a, RealType b = 1.0); // C++20
0535 explicit uniform_real_distribution(const param_type& parm);
0536 void reset();
0537
0538 // generating functions
0539 template<class URNG> result_type operator()(URNG& g);
0540 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0541
0542 // property functions
0543 result_type a() const;
0544 result_type b() const;
0545
0546 param_type param() const;
0547 void param(const param_type& parm);
0548
0549 result_type min() const;
0550 result_type max() const;
0551
0552 friend bool operator==(const uniform_real_distribution& x,
0553 const uniform_real_distribution& y);
0554 friend bool operator!=(const uniform_real_distribution& x,
0555 const uniform_real_distribution& y);
0556
0557 template <class charT, class traits>
0558 friend
0559 basic_ostream<charT, traits>&
0560 operator<<(basic_ostream<charT, traits>& os,
0561 const uniform_real_distribution& x);
0562
0563 template <class charT, class traits>
0564 friend
0565 basic_istream<charT, traits>&
0566 operator>>(basic_istream<charT, traits>& is,
0567 uniform_real_distribution& x);
0568 };
0569
0570 class bernoulli_distribution
0571 {
0572 public:
0573 // types
0574 typedef bool result_type;
0575
0576 class param_type
0577 {
0578 public:
0579 typedef bernoulli_distribution distribution_type;
0580
0581 explicit param_type(double p = 0.5);
0582
0583 double p() const;
0584
0585 friend bool operator==(const param_type& x, const param_type& y);
0586 friend bool operator!=(const param_type& x, const param_type& y);
0587 };
0588
0589 // constructors and reset functions
0590 explicit bernoulli_distribution(double p = 0.5); // before C++20
0591 bernoulli_distribution() : bernoulli_distribution(0.5) {} // C++20
0592 explicit bernoulli_distribution(double p); // C++20
0593 explicit bernoulli_distribution(const param_type& parm);
0594 void reset();
0595
0596 // generating functions
0597 template<class URNG> result_type operator()(URNG& g);
0598 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0599
0600 // property functions
0601 double p() const;
0602
0603 param_type param() const;
0604 void param(const param_type& parm);
0605
0606 result_type min() const;
0607 result_type max() const;
0608
0609 friend bool operator==(const bernoulli_distribution& x,
0610 const bernoulli_distribution& y);
0611 friend bool operator!=(const bernoulli_distribution& x,
0612 const bernoulli_distribution& y);
0613
0614 template <class charT, class traits>
0615 friend
0616 basic_ostream<charT, traits>&
0617 operator<<(basic_ostream<charT, traits>& os,
0618 const bernoulli_distribution& x);
0619
0620 template <class charT, class traits>
0621 friend
0622 basic_istream<charT, traits>&
0623 operator>>(basic_istream<charT, traits>& is,
0624 bernoulli_distribution& x);
0625 };
0626
0627 template<class IntType = int>
0628 class binomial_distribution
0629 {
0630 public:
0631 // types
0632 typedef IntType result_type;
0633
0634 class param_type
0635 {
0636 public:
0637 typedef binomial_distribution distribution_type;
0638
0639 explicit param_type(IntType t = 1, double p = 0.5);
0640
0641 IntType t() const;
0642 double p() const;
0643
0644 friend bool operator==(const param_type& x, const param_type& y);
0645 friend bool operator!=(const param_type& x, const param_type& y);
0646 };
0647
0648 // constructors and reset functions
0649 explicit binomial_distribution(IntType t = 1, double p = 0.5); // before C++20
0650 binomial_distribution() : binomial_distribution(1) {} // C++20
0651 explicit binomial_distribution(IntType t, double p = 0.5); // C++20
0652 explicit binomial_distribution(const param_type& parm);
0653 void reset();
0654
0655 // generating functions
0656 template<class URNG> result_type operator()(URNG& g);
0657 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0658
0659 // property functions
0660 IntType t() const;
0661 double p() const;
0662
0663 param_type param() const;
0664 void param(const param_type& parm);
0665
0666 result_type min() const;
0667 result_type max() const;
0668
0669 friend bool operator==(const binomial_distribution& x,
0670 const binomial_distribution& y);
0671 friend bool operator!=(const binomial_distribution& x,
0672 const binomial_distribution& y);
0673
0674 template <class charT, class traits>
0675 friend
0676 basic_ostream<charT, traits>&
0677 operator<<(basic_ostream<charT, traits>& os,
0678 const binomial_distribution& x);
0679
0680 template <class charT, class traits>
0681 friend
0682 basic_istream<charT, traits>&
0683 operator>>(basic_istream<charT, traits>& is,
0684 binomial_distribution& x);
0685 };
0686
0687 template<class IntType = int>
0688 class geometric_distribution
0689 {
0690 public:
0691 // types
0692 typedef IntType result_type;
0693
0694 class param_type
0695 {
0696 public:
0697 typedef geometric_distribution distribution_type;
0698
0699 explicit param_type(double p = 0.5);
0700
0701 double p() const;
0702
0703 friend bool operator==(const param_type& x, const param_type& y);
0704 friend bool operator!=(const param_type& x, const param_type& y);
0705 };
0706
0707 // constructors and reset functions
0708 explicit geometric_distribution(double p = 0.5); // before C++20
0709 geometric_distribution() : geometric_distribution(0.5) {} // C++20
0710 explicit geometric_distribution(double p); // C++20
0711 explicit geometric_distribution(const param_type& parm);
0712 void reset();
0713
0714 // generating functions
0715 template<class URNG> result_type operator()(URNG& g);
0716 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0717
0718 // property functions
0719 double p() const;
0720
0721 param_type param() const;
0722 void param(const param_type& parm);
0723
0724 result_type min() const;
0725 result_type max() const;
0726
0727 friend bool operator==(const geometric_distribution& x,
0728 const geometric_distribution& y);
0729 friend bool operator!=(const geometric_distribution& x,
0730 const geometric_distribution& y);
0731
0732 template <class charT, class traits>
0733 friend
0734 basic_ostream<charT, traits>&
0735 operator<<(basic_ostream<charT, traits>& os,
0736 const geometric_distribution& x);
0737
0738 template <class charT, class traits>
0739 friend
0740 basic_istream<charT, traits>&
0741 operator>>(basic_istream<charT, traits>& is,
0742 geometric_distribution& x);
0743 };
0744
0745 template<class IntType = int>
0746 class negative_binomial_distribution
0747 {
0748 public:
0749 // types
0750 typedef IntType result_type;
0751
0752 class param_type
0753 {
0754 public:
0755 typedef negative_binomial_distribution distribution_type;
0756
0757 explicit param_type(result_type k = 1, double p = 0.5);
0758
0759 result_type k() const;
0760 double p() const;
0761
0762 friend bool operator==(const param_type& x, const param_type& y);
0763 friend bool operator!=(const param_type& x, const param_type& y);
0764 };
0765
0766 // constructor and reset functions
0767 explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); // before C++20
0768 negative_binomial_distribution() : negative_binomial_distribution(1) {} // C++20
0769 explicit negative_binomial_distribution(IntType k, double p = 0.5); // C++20
0770 explicit negative_binomial_distribution(const param_type& parm);
0771 void reset();
0772
0773 // generating functions
0774 template<class URNG> result_type operator()(URNG& g);
0775 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0776
0777 // property functions
0778 result_type k() const;
0779 double p() const;
0780
0781 param_type param() const;
0782 void param(const param_type& parm);
0783
0784 result_type min() const;
0785 result_type max() const;
0786
0787 friend bool operator==(const negative_binomial_distribution& x,
0788 const negative_binomial_distribution& y);
0789 friend bool operator!=(const negative_binomial_distribution& x,
0790 const negative_binomial_distribution& y);
0791
0792 template <class charT, class traits>
0793 friend
0794 basic_ostream<charT, traits>&
0795 operator<<(basic_ostream<charT, traits>& os,
0796 const negative_binomial_distribution& x);
0797
0798 template <class charT, class traits>
0799 friend
0800 basic_istream<charT, traits>&
0801 operator>>(basic_istream<charT, traits>& is,
0802 negative_binomial_distribution& x);
0803 };
0804
0805 template<class IntType = int>
0806 class poisson_distribution
0807 {
0808 public:
0809 // types
0810 typedef IntType result_type;
0811
0812 class param_type
0813 {
0814 public:
0815 typedef poisson_distribution distribution_type;
0816
0817 explicit param_type(double mean = 1.0);
0818
0819 double mean() const;
0820
0821 friend bool operator==(const param_type& x, const param_type& y);
0822 friend bool operator!=(const param_type& x, const param_type& y);
0823 };
0824
0825 // constructors and reset functions
0826 explicit poisson_distribution(double mean = 1.0); // before C++20
0827 poisson_distribution() : poisson_distribution(1.0) {} // C++20
0828 explicit poisson_distribution(double mean); // C++20
0829 explicit poisson_distribution(const param_type& parm);
0830 void reset();
0831
0832 // generating functions
0833 template<class URNG> result_type operator()(URNG& g);
0834 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0835
0836 // property functions
0837 double mean() const;
0838
0839 param_type param() const;
0840 void param(const param_type& parm);
0841
0842 result_type min() const;
0843 result_type max() const;
0844
0845 friend bool operator==(const poisson_distribution& x,
0846 const poisson_distribution& y);
0847 friend bool operator!=(const poisson_distribution& x,
0848 const poisson_distribution& y);
0849
0850 template <class charT, class traits>
0851 friend
0852 basic_ostream<charT, traits>&
0853 operator<<(basic_ostream<charT, traits>& os,
0854 const poisson_distribution& x);
0855
0856 template <class charT, class traits>
0857 friend
0858 basic_istream<charT, traits>&
0859 operator>>(basic_istream<charT, traits>& is,
0860 poisson_distribution& x);
0861 };
0862
0863 template<class RealType = double>
0864 class exponential_distribution
0865 {
0866 public:
0867 // types
0868 typedef RealType result_type;
0869
0870 class param_type
0871 {
0872 public:
0873 typedef exponential_distribution distribution_type;
0874
0875 explicit param_type(result_type lambda = 1.0);
0876
0877 result_type lambda() const;
0878
0879 friend bool operator==(const param_type& x, const param_type& y);
0880 friend bool operator!=(const param_type& x, const param_type& y);
0881 };
0882
0883 // constructors and reset functions
0884 explicit exponential_distribution(RealType lambda = 1.0); // before C++20
0885 exponential_distribution() : exponential_distribution(1.0) {} // C++20
0886 explicit exponential_distribution(RealType lambda); // C++20
0887 explicit exponential_distribution(const param_type& parm);
0888 void reset();
0889
0890 // generating functions
0891 template<class URNG> result_type operator()(URNG& g);
0892 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0893
0894 // property functions
0895 result_type lambda() const;
0896
0897 param_type param() const;
0898 void param(const param_type& parm);
0899
0900 result_type min() const;
0901 result_type max() const;
0902
0903 friend bool operator==(const exponential_distribution& x,
0904 const exponential_distribution& y);
0905 friend bool operator!=(const exponential_distribution& x,
0906 const exponential_distribution& y);
0907
0908 template <class charT, class traits>
0909 friend
0910 basic_ostream<charT, traits>&
0911 operator<<(basic_ostream<charT, traits>& os,
0912 const exponential_distribution& x);
0913
0914 template <class charT, class traits>
0915 friend
0916 basic_istream<charT, traits>&
0917 operator>>(basic_istream<charT, traits>& is,
0918 exponential_distribution& x);
0919 };
0920
0921 template<class RealType = double>
0922 class gamma_distribution
0923 {
0924 public:
0925 // types
0926 typedef RealType result_type;
0927
0928 class param_type
0929 {
0930 public:
0931 typedef gamma_distribution distribution_type;
0932
0933 explicit param_type(result_type alpha = 1, result_type beta = 1);
0934
0935 result_type alpha() const;
0936 result_type beta() const;
0937
0938 friend bool operator==(const param_type& x, const param_type& y);
0939 friend bool operator!=(const param_type& x, const param_type& y);
0940 };
0941
0942 // constructors and reset functions
0943 explicit gamma_distribution(RealType alpha = 0.0, RealType beta = 1.0); // before C++20
0944 gamma_distribution() : gamma_distribution(0.0) {} // C++20
0945 explicit gamma_distribution(RealType alpha, RealType beta = 1.0); // C++20
0946 explicit gamma_distribution(const param_type& parm);
0947 void reset();
0948
0949 // generating functions
0950 template<class URNG> result_type operator()(URNG& g);
0951 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
0952
0953 // property functions
0954 result_type alpha() const;
0955 result_type beta() const;
0956
0957 param_type param() const;
0958 void param(const param_type& parm);
0959
0960 result_type min() const;
0961 result_type max() const;
0962
0963 friend bool operator==(const gamma_distribution& x,
0964 const gamma_distribution& y);
0965 friend bool operator!=(const gamma_distribution& x,
0966 const gamma_distribution& y);
0967
0968 template <class charT, class traits>
0969 friend
0970 basic_ostream<charT, traits>&
0971 operator<<(basic_ostream<charT, traits>& os,
0972 const gamma_distribution& x);
0973
0974 template <class charT, class traits>
0975 friend
0976 basic_istream<charT, traits>&
0977 operator>>(basic_istream<charT, traits>& is,
0978 gamma_distribution& x);
0979 };
0980
0981 template<class RealType = double>
0982 class weibull_distribution
0983 {
0984 public:
0985 // types
0986 typedef RealType result_type;
0987
0988 class param_type
0989 {
0990 public:
0991 typedef weibull_distribution distribution_type;
0992
0993 explicit param_type(result_type alpha = 1, result_type beta = 1);
0994
0995 result_type a() const;
0996 result_type b() const;
0997
0998 friend bool operator==(const param_type& x, const param_type& y);
0999 friend bool operator!=(const param_type& x, const param_type& y);
1000 };
1001
1002 // constructor and reset functions
1003 explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); // before C++20
1004 weibull_distribution() : weibull_distribution(1.0) {} // C++20
1005 explicit weibull_distribution(RealType a, RealType b = 1.0); // C++20
1006 explicit weibull_distribution(const param_type& parm);
1007 void reset();
1008
1009 // generating functions
1010 template<class URNG> result_type operator()(URNG& g);
1011 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1012
1013 // property functions
1014 result_type a() const;
1015 result_type b() const;
1016
1017 param_type param() const;
1018 void param(const param_type& parm);
1019
1020 result_type min() const;
1021 result_type max() const;
1022
1023 friend bool operator==(const weibull_distribution& x,
1024 const weibull_distribution& y);
1025 friend bool operator!=(const weibull_distribution& x,
1026 const weibull_distribution& y);
1027
1028 template <class charT, class traits>
1029 friend
1030 basic_ostream<charT, traits>&
1031 operator<<(basic_ostream<charT, traits>& os,
1032 const weibull_distribution& x);
1033
1034 template <class charT, class traits>
1035 friend
1036 basic_istream<charT, traits>&
1037 operator>>(basic_istream<charT, traits>& is,
1038 weibull_distribution& x);
1039 };
1040
1041 template<class RealType = double>
1042 class extreme_value_distribution
1043 {
1044 public:
1045 // types
1046 typedef RealType result_type;
1047
1048 class param_type
1049 {
1050 public:
1051 typedef extreme_value_distribution distribution_type;
1052
1053 explicit param_type(result_type a = 0, result_type b = 1);
1054
1055 result_type a() const;
1056 result_type b() const;
1057
1058 friend bool operator==(const param_type& x, const param_type& y);
1059 friend bool operator!=(const param_type& x, const param_type& y);
1060 };
1061
1062 // constructor and reset functions
1063 explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
1064 extreme_value_distribution() : extreme_value_distribution(0.0) {} // C++20
1065 explicit extreme_value_distribution(RealType a, RealType b = 1.0); // C++20
1066 explicit extreme_value_distribution(const param_type& parm);
1067 void reset();
1068
1069 // generating functions
1070 template<class URNG> result_type operator()(URNG& g);
1071 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1072
1073 // property functions
1074 result_type a() const;
1075 result_type b() const;
1076
1077 param_type param() const;
1078 void param(const param_type& parm);
1079
1080 result_type min() const;
1081 result_type max() const;
1082
1083 friend bool operator==(const extreme_value_distribution& x,
1084 const extreme_value_distribution& y);
1085 friend bool operator!=(const extreme_value_distribution& x,
1086 const extreme_value_distribution& y);
1087
1088 template <class charT, class traits>
1089 friend
1090 basic_ostream<charT, traits>&
1091 operator<<(basic_ostream<charT, traits>& os,
1092 const extreme_value_distribution& x);
1093
1094 template <class charT, class traits>
1095 friend
1096 basic_istream<charT, traits>&
1097 operator>>(basic_istream<charT, traits>& is,
1098 extreme_value_distribution& x);
1099 };
1100
1101 template<class RealType = double>
1102 class normal_distribution
1103 {
1104 public:
1105 // types
1106 typedef RealType result_type;
1107
1108 class param_type
1109 {
1110 public:
1111 typedef normal_distribution distribution_type;
1112
1113 explicit param_type(result_type mean = 0, result_type stddev = 1);
1114
1115 result_type mean() const;
1116 result_type stddev() const;
1117
1118 friend bool operator==(const param_type& x, const param_type& y);
1119 friend bool operator!=(const param_type& x, const param_type& y);
1120 };
1121
1122 // constructors and reset functions
1123 explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
1124 normal_distribution() : normal_distribution(0.0) {} // C++20
1125 explicit normal_distribution(RealType mean, RealType stddev = 1.0); // C++20
1126 explicit normal_distribution(const param_type& parm);
1127 void reset();
1128
1129 // generating functions
1130 template<class URNG> result_type operator()(URNG& g);
1131 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1132
1133 // property functions
1134 result_type mean() const;
1135 result_type stddev() const;
1136
1137 param_type param() const;
1138 void param(const param_type& parm);
1139
1140 result_type min() const;
1141 result_type max() const;
1142
1143 friend bool operator==(const normal_distribution& x,
1144 const normal_distribution& y);
1145 friend bool operator!=(const normal_distribution& x,
1146 const normal_distribution& y);
1147
1148 template <class charT, class traits>
1149 friend
1150 basic_ostream<charT, traits>&
1151 operator<<(basic_ostream<charT, traits>& os,
1152 const normal_distribution& x);
1153
1154 template <class charT, class traits>
1155 friend
1156 basic_istream<charT, traits>&
1157 operator>>(basic_istream<charT, traits>& is,
1158 normal_distribution& x);
1159 };
1160
1161 template<class RealType = double>
1162 class lognormal_distribution
1163 {
1164 public:
1165 // types
1166 typedef RealType result_type;
1167
1168 class param_type
1169 {
1170 public:
1171 typedef lognormal_distribution distribution_type;
1172
1173 explicit param_type(result_type m = 0, result_type s = 1);
1174
1175 result_type m() const;
1176 result_type s() const;
1177
1178 friend bool operator==(const param_type& x, const param_type& y);
1179 friend bool operator!=(const param_type& x, const param_type& y);
1180 };
1181
1182 // constructor and reset functions
1183 explicit lognormal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
1184 lognormal_distribution() : lognormal_distribution(0.0) {} // C++20
1185 explicit lognormal_distribution(RealType mean, RealType stddev = 1.0); // C++20
1186 explicit lognormal_distribution(const param_type& parm);
1187 void reset();
1188
1189 // generating functions
1190 template<class URNG> result_type operator()(URNG& g);
1191 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1192
1193 // property functions
1194 result_type m() const;
1195 result_type s() const;
1196
1197 param_type param() const;
1198 void param(const param_type& parm);
1199
1200 result_type min() const;
1201 result_type max() const;
1202
1203 friend bool operator==(const lognormal_distribution& x,
1204 const lognormal_distribution& y);
1205 friend bool operator!=(const lognormal_distribution& x,
1206 const lognormal_distribution& y);
1207
1208 template <class charT, class traits>
1209 friend
1210 basic_ostream<charT, traits>&
1211 operator<<(basic_ostream<charT, traits>& os,
1212 const lognormal_distribution& x);
1213
1214 template <class charT, class traits>
1215 friend
1216 basic_istream<charT, traits>&
1217 operator>>(basic_istream<charT, traits>& is,
1218 lognormal_distribution& x);
1219 };
1220
1221 template<class RealType = double>
1222 class chi_squared_distribution
1223 {
1224 public:
1225 // types
1226 typedef RealType result_type;
1227
1228 class param_type
1229 {
1230 public:
1231 typedef chi_squared_distribution distribution_type;
1232
1233 explicit param_type(result_type n = 1);
1234
1235 result_type n() const;
1236
1237 friend bool operator==(const param_type& x, const param_type& y);
1238 friend bool operator!=(const param_type& x, const param_type& y);
1239 };
1240
1241 // constructor and reset functions
1242 explicit chi_squared_distribution(RealType n = 1.0); // before C++20
1243 chi_squared_distribution() : chi_squared_distribution(1.0) {} // C++20
1244 explicit chi_squared_distribution(RealType n); // C++20
1245 explicit chi_squared_distribution(const param_type& parm);
1246 void reset();
1247
1248 // generating functions
1249 template<class URNG> result_type operator()(URNG& g);
1250 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1251
1252 // property functions
1253 result_type n() const;
1254
1255 param_type param() const;
1256 void param(const param_type& parm);
1257
1258 result_type min() const;
1259 result_type max() const;
1260
1261 friend bool operator==(const chi_squared_distribution& x,
1262 const chi_squared_distribution& y);
1263 friend bool operator!=(const chi_squared_distribution& x,
1264 const chi_squared_distribution& y);
1265
1266 template <class charT, class traits>
1267 friend
1268 basic_ostream<charT, traits>&
1269 operator<<(basic_ostream<charT, traits>& os,
1270 const chi_squared_distribution& x);
1271
1272 template <class charT, class traits>
1273 friend
1274 basic_istream<charT, traits>&
1275 operator>>(basic_istream<charT, traits>& is,
1276 chi_squared_distribution& x);
1277 };
1278
1279 template<class RealType = double>
1280 class cauchy_distribution
1281 {
1282 public:
1283 // types
1284 typedef RealType result_type;
1285
1286 class param_type
1287 {
1288 public:
1289 typedef cauchy_distribution distribution_type;
1290
1291 explicit param_type(result_type a = 0, result_type b = 1);
1292
1293 result_type a() const;
1294 result_type b() const;
1295
1296 friend bool operator==(const param_type& x, const param_type& y);
1297 friend bool operator!=(const param_type& x, const param_type& y);
1298 };
1299
1300 // constructor and reset functions
1301 explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
1302 cauchy_distribution() : cauchy_distribution(0.0) {} // C++20
1303 explicit cauchy_distribution(RealType a, RealType b = 1.0); // C++20
1304 explicit cauchy_distribution(const param_type& parm);
1305 void reset();
1306
1307 // generating functions
1308 template<class URNG> result_type operator()(URNG& g);
1309 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1310
1311 // property functions
1312 result_type a() const;
1313 result_type b() const;
1314
1315 param_type param() const;
1316 void param(const param_type& parm);
1317
1318 result_type min() const;
1319 result_type max() const;
1320
1321 friend bool operator==(const cauchy_distribution& x,
1322 const cauchy_distribution& y);
1323 friend bool operator!=(const cauchy_distribution& x,
1324 const cauchy_distribution& y);
1325
1326 template <class charT, class traits>
1327 friend
1328 basic_ostream<charT, traits>&
1329 operator<<(basic_ostream<charT, traits>& os,
1330 const cauchy_distribution& x);
1331
1332 template <class charT, class traits>
1333 friend
1334 basic_istream<charT, traits>&
1335 operator>>(basic_istream<charT, traits>& is,
1336 cauchy_distribution& x);
1337 };
1338
1339 template<class RealType = double>
1340 class fisher_f_distribution
1341 {
1342 public:
1343 // types
1344 typedef RealType result_type;
1345
1346 class param_type
1347 {
1348 public:
1349 typedef fisher_f_distribution distribution_type;
1350
1351 explicit param_type(result_type m = 1, result_type n = 1);
1352
1353 result_type m() const;
1354 result_type n() const;
1355
1356 friend bool operator==(const param_type& x, const param_type& y);
1357 friend bool operator!=(const param_type& x, const param_type& y);
1358 };
1359
1360 // constructor and reset functions
1361 explicit fisher_f_distribution(RealType m = 1.0, RealType n = 1.0); // before C++20
1362 fisher_f_distribution() : fisher_f_distribution(1.0) {} // C++20
1363 explicit fisher_f_distribution(RealType m, RealType n = 1.0); // C++20
1364 explicit fisher_f_distribution(const param_type& parm);
1365 void reset();
1366
1367 // generating functions
1368 template<class URNG> result_type operator()(URNG& g);
1369 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1370
1371 // property functions
1372 result_type m() const;
1373 result_type n() const;
1374
1375 param_type param() const;
1376 void param(const param_type& parm);
1377
1378 result_type min() const;
1379 result_type max() const;
1380
1381 friend bool operator==(const fisher_f_distribution& x,
1382 const fisher_f_distribution& y);
1383 friend bool operator!=(const fisher_f_distribution& x,
1384 const fisher_f_distribution& y);
1385
1386 template <class charT, class traits>
1387 friend
1388 basic_ostream<charT, traits>&
1389 operator<<(basic_ostream<charT, traits>& os,
1390 const fisher_f_distribution& x);
1391
1392 template <class charT, class traits>
1393 friend
1394 basic_istream<charT, traits>&
1395 operator>>(basic_istream<charT, traits>& is,
1396 fisher_f_distribution& x);
1397 };
1398
1399 template<class RealType = double>
1400 class student_t_distribution
1401 {
1402 public:
1403 // types
1404 typedef RealType result_type;
1405
1406 class param_type
1407 {
1408 public:
1409 typedef student_t_distribution distribution_type;
1410
1411 explicit param_type(result_type n = 1);
1412
1413 result_type n() const;
1414
1415 friend bool operator==(const param_type& x, const param_type& y);
1416 friend bool operator!=(const param_type& x, const param_type& y);
1417 };
1418
1419 // constructor and reset functions
1420 explicit student_t_distribution(RealType n = 1.0); // before C++20
1421 student_t_distribution() : student_t_distribution(1.0) {} // C++20
1422 explicit student_t_distribution(RealType n); // C++20
1423 explicit student_t_distribution(const param_type& parm);
1424 void reset();
1425
1426 // generating functions
1427 template<class URNG> result_type operator()(URNG& g);
1428 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1429
1430 // property functions
1431 result_type n() const;
1432
1433 param_type param() const;
1434 void param(const param_type& parm);
1435
1436 result_type min() const;
1437 result_type max() const;
1438
1439 friend bool operator==(const student_t_distribution& x,
1440 const student_t_distribution& y);
1441 friend bool operator!=(const student_t_distribution& x,
1442 const student_t_distribution& y);
1443
1444 template <class charT, class traits>
1445 friend
1446 basic_ostream<charT, traits>&
1447 operator<<(basic_ostream<charT, traits>& os,
1448 const student_t_distribution& x);
1449
1450 template <class charT, class traits>
1451 friend
1452 basic_istream<charT, traits>&
1453 operator>>(basic_istream<charT, traits>& is,
1454 student_t_distribution& x);
1455 };
1456
1457 template<class IntType = int>
1458 class discrete_distribution
1459 {
1460 public:
1461 // types
1462 typedef IntType result_type;
1463
1464 class param_type
1465 {
1466 public:
1467 typedef discrete_distribution distribution_type;
1468
1469 param_type();
1470 template<class InputIterator>
1471 param_type(InputIterator firstW, InputIterator lastW);
1472 param_type(initializer_list<double> wl);
1473 template<class UnaryOperation>
1474 param_type(size_t nw, double xmin, double xmax, UnaryOperation fw);
1475
1476 vector<double> probabilities() const;
1477
1478 friend bool operator==(const param_type& x, const param_type& y);
1479 friend bool operator!=(const param_type& x, const param_type& y);
1480 };
1481
1482 // constructor and reset functions
1483 discrete_distribution();
1484 template<class InputIterator>
1485 discrete_distribution(InputIterator firstW, InputIterator lastW);
1486 discrete_distribution(initializer_list<double> wl);
1487 template<class UnaryOperation>
1488 discrete_distribution(size_t nw, double xmin, double xmax,
1489 UnaryOperation fw);
1490 explicit discrete_distribution(const param_type& parm);
1491 void reset();
1492
1493 // generating functions
1494 template<class URNG> result_type operator()(URNG& g);
1495 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1496
1497 // property functions
1498 vector<double> probabilities() const;
1499
1500 param_type param() const;
1501 void param(const param_type& parm);
1502
1503 result_type min() const;
1504 result_type max() const;
1505
1506 friend bool operator==(const discrete_distribution& x,
1507 const discrete_distribution& y);
1508 friend bool operator!=(const discrete_distribution& x,
1509 const discrete_distribution& y);
1510
1511 template <class charT, class traits>
1512 friend
1513 basic_ostream<charT, traits>&
1514 operator<<(basic_ostream<charT, traits>& os,
1515 const discrete_distribution& x);
1516
1517 template <class charT, class traits>
1518 friend
1519 basic_istream<charT, traits>&
1520 operator>>(basic_istream<charT, traits>& is,
1521 discrete_distribution& x);
1522 };
1523
1524 template<class RealType = double>
1525 class piecewise_constant_distribution
1526 {
1527 // types
1528 typedef RealType result_type;
1529
1530 class param_type
1531 {
1532 public:
1533 typedef piecewise_constant_distribution distribution_type;
1534
1535 param_type();
1536 template<class InputIteratorB, class InputIteratorW>
1537 param_type(InputIteratorB firstB, InputIteratorB lastB,
1538 InputIteratorW firstW);
1539 template<class UnaryOperation>
1540 param_type(initializer_list<result_type> bl, UnaryOperation fw);
1541 template<class UnaryOperation>
1542 param_type(size_t nw, result_type xmin, result_type xmax,
1543 UnaryOperation fw);
1544
1545 vector<result_type> intervals() const;
1546 vector<result_type> densities() const;
1547
1548 friend bool operator==(const param_type& x, const param_type& y);
1549 friend bool operator!=(const param_type& x, const param_type& y);
1550 };
1551
1552 // constructor and reset functions
1553 piecewise_constant_distribution();
1554 template<class InputIteratorB, class InputIteratorW>
1555 piecewise_constant_distribution(InputIteratorB firstB,
1556 InputIteratorB lastB,
1557 InputIteratorW firstW);
1558 template<class UnaryOperation>
1559 piecewise_constant_distribution(initializer_list<result_type> bl,
1560 UnaryOperation fw);
1561 template<class UnaryOperation>
1562 piecewise_constant_distribution(size_t nw, result_type xmin,
1563 result_type xmax, UnaryOperation fw);
1564 explicit piecewise_constant_distribution(const param_type& parm);
1565 void reset();
1566
1567 // generating functions
1568 template<class URNG> result_type operator()(URNG& g);
1569 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1570
1571 // property functions
1572 vector<result_type> intervals() const;
1573 vector<result_type> densities() const;
1574
1575 param_type param() const;
1576 void param(const param_type& parm);
1577
1578 result_type min() const;
1579 result_type max() const;
1580
1581 friend bool operator==(const piecewise_constant_distribution& x,
1582 const piecewise_constant_distribution& y);
1583 friend bool operator!=(const piecewise_constant_distribution& x,
1584 const piecewise_constant_distribution& y);
1585
1586 template <class charT, class traits>
1587 friend
1588 basic_ostream<charT, traits>&
1589 operator<<(basic_ostream<charT, traits>& os,
1590 const piecewise_constant_distribution& x);
1591
1592 template <class charT, class traits>
1593 friend
1594 basic_istream<charT, traits>&
1595 operator>>(basic_istream<charT, traits>& is,
1596 piecewise_constant_distribution& x);
1597 };
1598
1599 template<class RealType = double>
1600 class piecewise_linear_distribution
1601 {
1602 // types
1603 typedef RealType result_type;
1604
1605 class param_type
1606 {
1607 public:
1608 typedef piecewise_linear_distribution distribution_type;
1609
1610 param_type();
1611 template<class InputIteratorB, class InputIteratorW>
1612 param_type(InputIteratorB firstB, InputIteratorB lastB,
1613 InputIteratorW firstW);
1614 template<class UnaryOperation>
1615 param_type(initializer_list<result_type> bl, UnaryOperation fw);
1616 template<class UnaryOperation>
1617 param_type(size_t nw, result_type xmin, result_type xmax,
1618 UnaryOperation fw);
1619
1620 vector<result_type> intervals() const;
1621 vector<result_type> densities() const;
1622
1623 friend bool operator==(const param_type& x, const param_type& y);
1624 friend bool operator!=(const param_type& x, const param_type& y);
1625 };
1626
1627 // constructor and reset functions
1628 piecewise_linear_distribution();
1629 template<class InputIteratorB, class InputIteratorW>
1630 piecewise_linear_distribution(InputIteratorB firstB,
1631 InputIteratorB lastB,
1632 InputIteratorW firstW);
1633
1634 template<class UnaryOperation>
1635 piecewise_linear_distribution(initializer_list<result_type> bl,
1636 UnaryOperation fw);
1637
1638 template<class UnaryOperation>
1639 piecewise_linear_distribution(size_t nw, result_type xmin,
1640 result_type xmax, UnaryOperation fw);
1641
1642 explicit piecewise_linear_distribution(const param_type& parm);
1643 void reset();
1644
1645 // generating functions
1646 template<class URNG> result_type operator()(URNG& g);
1647 template<class URNG> result_type operator()(URNG& g, const param_type& parm);
1648
1649 // property functions
1650 vector<result_type> intervals() const;
1651 vector<result_type> densities() const;
1652
1653 param_type param() const;
1654 void param(const param_type& parm);
1655
1656 result_type min() const;
1657 result_type max() const;
1658
1659 friend bool operator==(const piecewise_linear_distribution& x,
1660 const piecewise_linear_distribution& y);
1661 friend bool operator!=(const piecewise_linear_distribution& x,
1662 const piecewise_linear_distribution& y);
1663
1664 template <class charT, class traits>
1665 friend
1666 basic_ostream<charT, traits>&
1667 operator<<(basic_ostream<charT, traits>& os,
1668 const piecewise_linear_distribution& x);
1669
1670 template <class charT, class traits>
1671 friend
1672 basic_istream<charT, traits>&
1673 operator>>(basic_istream<charT, traits>& is,
1674 piecewise_linear_distribution& x);
1675 };
1676
1677 } // std
1678 */
1679
1680 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1681 # include <__cxx03/random>
1682 #else
1683 # include <__config>
1684 # include <__random/bernoulli_distribution.h>
1685 # include <__random/binomial_distribution.h>
1686 # include <__random/cauchy_distribution.h>
1687 # include <__random/chi_squared_distribution.h>
1688 # include <__random/default_random_engine.h>
1689 # include <__random/discard_block_engine.h>
1690 # include <__random/discrete_distribution.h>
1691 # include <__random/exponential_distribution.h>
1692 # include <__random/extreme_value_distribution.h>
1693 # include <__random/fisher_f_distribution.h>
1694 # include <__random/gamma_distribution.h>
1695 # include <__random/generate_canonical.h>
1696 # include <__random/geometric_distribution.h>
1697 # include <__random/independent_bits_engine.h>
1698 # include <__random/is_seed_sequence.h>
1699 # include <__random/knuth_b.h>
1700 # include <__random/linear_congruential_engine.h>
1701 # include <__random/lognormal_distribution.h>
1702 # include <__random/mersenne_twister_engine.h>
1703 # include <__random/negative_binomial_distribution.h>
1704 # include <__random/normal_distribution.h>
1705 # include <__random/piecewise_constant_distribution.h>
1706 # include <__random/piecewise_linear_distribution.h>
1707 # include <__random/poisson_distribution.h>
1708 # include <__random/random_device.h>
1709 # include <__random/ranlux.h>
1710 # include <__random/seed_seq.h>
1711 # include <__random/shuffle_order_engine.h>
1712 # include <__random/student_t_distribution.h>
1713 # include <__random/subtract_with_carry_engine.h>
1714 # include <__random/uniform_int_distribution.h>
1715 # include <__random/uniform_random_bit_generator.h>
1716 # include <__random/uniform_real_distribution.h>
1717 # include <__random/weibull_distribution.h>
1718 # include <version>
1719
1720 // standard-mandated includes
1721
1722 // [rand.synopsis]
1723 # include <initializer_list>
1724
1725 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1726 # pragma GCC system_header
1727 # endif
1728
1729 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1730 # include <algorithm>
1731 # include <climits>
1732 # include <cmath>
1733 # include <concepts>
1734 # include <cstddef>
1735 # include <cstdint>
1736 # include <cstdlib>
1737 # include <iosfwd>
1738 # include <limits>
1739 # include <numeric>
1740 # include <string>
1741 # include <type_traits>
1742 # include <vector>
1743 # endif
1744 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
1745
1746 #endif // _LIBCPP_RANDOM