random 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_RANDOM
  10. #define _LIBCPP_RANDOM
  11. /*
  12. random synopsis
  13. #include <initializer_list>
  14. namespace std
  15. {
  16. // [rand.req.urng], uniform random bit generator requirements
  17. template<class G>
  18. concept uniform_random_bit_generator = see below; // C++20
  19. // Engines
  20. template <class UIntType, UIntType a, UIntType c, UIntType m>
  21. class linear_congruential_engine
  22. {
  23. public:
  24. // types
  25. typedef UIntType result_type;
  26. // engine characteristics
  27. static constexpr result_type multiplier = a;
  28. static constexpr result_type increment = c;
  29. static constexpr result_type modulus = m;
  30. static constexpr result_type min() { return c == 0u ? 1u: 0u;}
  31. static constexpr result_type max() { return m - 1u;}
  32. static constexpr result_type default_seed = 1u;
  33. // constructors and seeding functions
  34. explicit linear_congruential_engine(result_type s = default_seed); // before C++20
  35. linear_congruential_engine() : linear_congruential_engine(default_seed) {} // C++20
  36. explicit linear_congruential_engine(result_type s); // C++20
  37. template<class Sseq> explicit linear_congruential_engine(Sseq& q);
  38. void seed(result_type s = default_seed);
  39. template<class Sseq> void seed(Sseq& q);
  40. // generating functions
  41. result_type operator()();
  42. void discard(unsigned long long z);
  43. };
  44. template <class UIntType, UIntType a, UIntType c, UIntType m>
  45. bool
  46. operator==(const linear_congruential_engine<UIntType, a, c, m>& x,
  47. const linear_congruential_engine<UIntType, a, c, m>& y);
  48. template <class UIntType, UIntType a, UIntType c, UIntType m>
  49. bool
  50. operator!=(const linear_congruential_engine<UIntType, a, c, m>& x,
  51. const linear_congruential_engine<UIntType, a, c, m>& y);
  52. template <class charT, class traits,
  53. class UIntType, UIntType a, UIntType c, UIntType m>
  54. basic_ostream<charT, traits>&
  55. operator<<(basic_ostream<charT, traits>& os,
  56. const linear_congruential_engine<UIntType, a, c, m>& x);
  57. template <class charT, class traits,
  58. class UIntType, UIntType a, UIntType c, UIntType m>
  59. basic_istream<charT, traits>&
  60. operator>>(basic_istream<charT, traits>& is,
  61. linear_congruential_engine<UIntType, a, c, m>& x);
  62. template <class UIntType, size_t w, size_t n, size_t m, size_t r,
  63. UIntType a, size_t u, UIntType d, size_t s,
  64. UIntType b, size_t t, UIntType c, size_t l, UIntType f>
  65. class mersenne_twister_engine
  66. {
  67. public:
  68. // types
  69. typedef UIntType result_type;
  70. // engine characteristics
  71. static constexpr size_t word_size = w;
  72. static constexpr size_t state_size = n;
  73. static constexpr size_t shift_size = m;
  74. static constexpr size_t mask_bits = r;
  75. static constexpr result_type xor_mask = a;
  76. static constexpr size_t tempering_u = u;
  77. static constexpr result_type tempering_d = d;
  78. static constexpr size_t tempering_s = s;
  79. static constexpr result_type tempering_b = b;
  80. static constexpr size_t tempering_t = t;
  81. static constexpr result_type tempering_c = c;
  82. static constexpr size_t tempering_l = l;
  83. static constexpr result_type initialization_multiplier = f;
  84. static constexpr result_type min () { return 0; }
  85. static constexpr result_type max() { return 2^w - 1; }
  86. static constexpr result_type default_seed = 5489u;
  87. // constructors and seeding functions
  88. explicit mersenne_twister_engine(result_type s = default_seed); // before C++20
  89. mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} // C++20
  90. explicit mersenne_twister_engine(result_type s); // C++20
  91. template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
  92. void seed(result_type value = default_seed);
  93. template<class Sseq> void seed(Sseq& q);
  94. // generating functions
  95. result_type operator()();
  96. void discard(unsigned long long z);
  97. };
  98. template <class UIntType, size_t w, size_t n, size_t m, size_t r,
  99. UIntType a, size_t u, UIntType d, size_t s,
  100. UIntType b, size_t t, UIntType c, size_t l, UIntType f>
  101. bool
  102. operator==(
  103. const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
  104. const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
  105. template <class UIntType, size_t w, size_t n, size_t m, size_t r,
  106. UIntType a, size_t u, UIntType d, size_t s,
  107. UIntType b, size_t t, UIntType c, size_t l, UIntType f>
  108. bool
  109. operator!=(
  110. const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
  111. const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
  112. template <class charT, class traits,
  113. class UIntType, size_t w, size_t n, size_t m, size_t r,
  114. UIntType a, size_t u, UIntType d, size_t s,
  115. UIntType b, size_t t, UIntType c, size_t l, UIntType f>
  116. basic_ostream<charT, traits>&
  117. operator<<(basic_ostream<charT, traits>& os,
  118. const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
  119. template <class charT, class traits,
  120. class UIntType, size_t w, size_t n, size_t m, size_t r,
  121. UIntType a, size_t u, UIntType d, size_t s,
  122. UIntType b, size_t t, UIntType c, size_t l, UIntType f>
  123. basic_istream<charT, traits>&
  124. operator>>(basic_istream<charT, traits>& is,
  125. mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
  126. template<class UIntType, size_t w, size_t s, size_t r>
  127. class subtract_with_carry_engine
  128. {
  129. public:
  130. // types
  131. typedef UIntType result_type;
  132. // engine characteristics
  133. static constexpr size_t word_size = w;
  134. static constexpr size_t short_lag = s;
  135. static constexpr size_t long_lag = r;
  136. static constexpr result_type min() { return 0; }
  137. static constexpr result_type max() { return m-1; }
  138. static constexpr result_type default_seed = 19780503u;
  139. // constructors and seeding functions
  140. explicit subtract_with_carry_engine(result_type value = default_seed); // before C++20
  141. subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} // C++20
  142. explicit subtract_with_carry_engine(result_type value); // C++20
  143. template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
  144. void seed(result_type value = default_seed);
  145. template<class Sseq> void seed(Sseq& q);
  146. // generating functions
  147. result_type operator()();
  148. void discard(unsigned long long z);
  149. };
  150. template<class UIntType, size_t w, size_t s, size_t r>
  151. bool
  152. operator==(
  153. const subtract_with_carry_engine<UIntType, w, s, r>& x,
  154. const subtract_with_carry_engine<UIntType, w, s, r>& y);
  155. template<class UIntType, size_t w, size_t s, size_t r>
  156. bool
  157. operator!=(
  158. const subtract_with_carry_engine<UIntType, w, s, r>& x,
  159. const subtract_with_carry_engine<UIntType, w, s, r>& y);
  160. template <class charT, class traits,
  161. class UIntType, size_t w, size_t s, size_t r>
  162. basic_ostream<charT, traits>&
  163. operator<<(basic_ostream<charT, traits>& os,
  164. const subtract_with_carry_engine<UIntType, w, s, r>& x);
  165. template <class charT, class traits,
  166. class UIntType, size_t w, size_t s, size_t r>
  167. basic_istream<charT, traits>&
  168. operator>>(basic_istream<charT, traits>& is,
  169. subtract_with_carry_engine<UIntType, w, s, r>& x);
  170. template<class Engine, size_t p, size_t r>
  171. class discard_block_engine
  172. {
  173. public:
  174. // types
  175. typedef typename Engine::result_type result_type;
  176. // engine characteristics
  177. static constexpr size_t block_size = p;
  178. static constexpr size_t used_block = r;
  179. static constexpr result_type min() { return Engine::min(); }
  180. static constexpr result_type max() { return Engine::max(); }
  181. // constructors and seeding functions
  182. discard_block_engine();
  183. explicit discard_block_engine(const Engine& e);
  184. explicit discard_block_engine(Engine&& e);
  185. explicit discard_block_engine(result_type s);
  186. template<class Sseq> explicit discard_block_engine(Sseq& q);
  187. void seed();
  188. void seed(result_type s);
  189. template<class Sseq> void seed(Sseq& q);
  190. // generating functions
  191. result_type operator()();
  192. void discard(unsigned long long z);
  193. // property functions
  194. const Engine& base() const noexcept;
  195. };
  196. template<class Engine, size_t p, size_t r>
  197. bool
  198. operator==(
  199. const discard_block_engine<Engine, p, r>& x,
  200. const discard_block_engine<Engine, p, r>& y);
  201. template<class Engine, size_t p, size_t r>
  202. bool
  203. operator!=(
  204. const discard_block_engine<Engine, p, r>& x,
  205. const discard_block_engine<Engine, p, r>& y);
  206. template <class charT, class traits,
  207. class Engine, size_t p, size_t r>
  208. basic_ostream<charT, traits>&
  209. operator<<(basic_ostream<charT, traits>& os,
  210. const discard_block_engine<Engine, p, r>& x);
  211. template <class charT, class traits,
  212. class Engine, size_t p, size_t r>
  213. basic_istream<charT, traits>&
  214. operator>>(basic_istream<charT, traits>& is,
  215. discard_block_engine<Engine, p, r>& x);
  216. template<class Engine, size_t w, class UIntType>
  217. class independent_bits_engine
  218. {
  219. public:
  220. // types
  221. typedef UIntType result_type;
  222. // engine characteristics
  223. static constexpr result_type min() { return 0; }
  224. static constexpr result_type max() { return 2^w - 1; }
  225. // constructors and seeding functions
  226. independent_bits_engine();
  227. explicit independent_bits_engine(const Engine& e);
  228. explicit independent_bits_engine(Engine&& e);
  229. explicit independent_bits_engine(result_type s);
  230. template<class Sseq> explicit independent_bits_engine(Sseq& q);
  231. void seed();
  232. void seed(result_type s);
  233. template<class Sseq> void seed(Sseq& q);
  234. // generating functions
  235. result_type operator()(); void discard(unsigned long long z);
  236. // property functions
  237. const Engine& base() const noexcept;
  238. };
  239. template<class Engine, size_t w, class UIntType>
  240. bool
  241. operator==(
  242. const independent_bits_engine<Engine, w, UIntType>& x,
  243. const independent_bits_engine<Engine, w, UIntType>& y);
  244. template<class Engine, size_t w, class UIntType>
  245. bool
  246. operator!=(
  247. const independent_bits_engine<Engine, w, UIntType>& x,
  248. const independent_bits_engine<Engine, w, UIntType>& y);
  249. template <class charT, class traits,
  250. class Engine, size_t w, class UIntType>
  251. basic_ostream<charT, traits>&
  252. operator<<(basic_ostream<charT, traits>& os,
  253. const independent_bits_engine<Engine, w, UIntType>& x);
  254. template <class charT, class traits,
  255. class Engine, size_t w, class UIntType>
  256. basic_istream<charT, traits>&
  257. operator>>(basic_istream<charT, traits>& is,
  258. independent_bits_engine<Engine, w, UIntType>& x);
  259. template<class Engine, size_t k>
  260. class shuffle_order_engine
  261. {
  262. public:
  263. // types
  264. typedef typename Engine::result_type result_type;
  265. // engine characteristics
  266. static constexpr size_t table_size = k;
  267. static constexpr result_type min() { return Engine::min; }
  268. static constexpr result_type max() { return Engine::max; }
  269. // constructors and seeding functions
  270. shuffle_order_engine();
  271. explicit shuffle_order_engine(const Engine& e);
  272. explicit shuffle_order_engine(Engine&& e);
  273. explicit shuffle_order_engine(result_type s);
  274. template<class Sseq> explicit shuffle_order_engine(Sseq& q);
  275. void seed();
  276. void seed(result_type s);
  277. template<class Sseq> void seed(Sseq& q);
  278. // generating functions
  279. result_type operator()();
  280. void discard(unsigned long long z);
  281. // property functions
  282. const Engine& base() const noexcept;
  283. };
  284. template<class Engine, size_t k>
  285. bool
  286. operator==(
  287. const shuffle_order_engine<Engine, k>& x,
  288. const shuffle_order_engine<Engine, k>& y);
  289. template<class Engine, size_t k>
  290. bool
  291. operator!=(
  292. const shuffle_order_engine<Engine, k>& x,
  293. const shuffle_order_engine<Engine, k>& y);
  294. template <class charT, class traits,
  295. class Engine, size_t k>
  296. basic_ostream<charT, traits>&
  297. operator<<(basic_ostream<charT, traits>& os,
  298. const shuffle_order_engine<Engine, k>& x);
  299. template <class charT, class traits,
  300. class Engine, size_t k>
  301. basic_istream<charT, traits>&
  302. operator>>(basic_istream<charT, traits>& is,
  303. shuffle_order_engine<Engine, k>& x);
  304. typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
  305. minstd_rand0;
  306. typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
  307. minstd_rand;
  308. typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
  309. 0x9908b0df,
  310. 11, 0xffffffff,
  311. 7, 0x9d2c5680,
  312. 15, 0xefc60000,
  313. 18, 1812433253> mt19937;
  314. typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
  315. 0xb5026f5aa96619e9,
  316. 29, 0x5555555555555555,
  317. 17, 0x71d67fffeda60000,
  318. 37, 0xfff7eee000000000,
  319. 43, 6364136223846793005> mt19937_64;
  320. typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base;
  321. typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base;
  322. typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
  323. typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
  324. typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
  325. typedef minstd_rand default_random_engine;
  326. // Generators
  327. class random_device
  328. {
  329. public:
  330. // types
  331. typedef unsigned int result_type;
  332. // generator characteristics
  333. static constexpr result_type min() { return numeric_limits<result_type>::min(); }
  334. static constexpr result_type max() { return numeric_limits<result_type>::max(); }
  335. // constructors
  336. explicit random_device(const string& token = implementation-defined); // before C++20
  337. random_device() : random_device(implementation-defined) {} // C++20
  338. explicit random_device(const string& token); // C++20
  339. // generating functions
  340. result_type operator()();
  341. // property functions
  342. double entropy() const noexcept;
  343. // no copy functions
  344. random_device(const random_device& ) = delete;
  345. void operator=(const random_device& ) = delete;
  346. };
  347. // Utilities
  348. class seed_seq
  349. {
  350. public:
  351. // types
  352. typedef uint_least32_t result_type;
  353. // constructors
  354. seed_seq();
  355. template<class T>
  356. seed_seq(initializer_list<T> il);
  357. template<class InputIterator>
  358. seed_seq(InputIterator begin, InputIterator end);
  359. // generating functions
  360. template<class RandomAccessIterator>
  361. void generate(RandomAccessIterator begin, RandomAccessIterator end);
  362. // property functions
  363. size_t size() const;
  364. template<class OutputIterator>
  365. void param(OutputIterator dest) const;
  366. // no copy functions
  367. seed_seq(const seed_seq&) = delete;
  368. void operator=(const seed_seq& ) = delete;
  369. };
  370. template<class RealType, size_t bits, class URNG>
  371. RealType generate_canonical(URNG& g);
  372. // Distributions
  373. template<class IntType = int>
  374. class uniform_int_distribution
  375. {
  376. public:
  377. // types
  378. typedef IntType result_type;
  379. class param_type
  380. {
  381. public:
  382. typedef uniform_int_distribution distribution_type;
  383. explicit param_type(IntType a = 0,
  384. IntType b = numeric_limits<IntType>::max());
  385. result_type a() const;
  386. result_type b() const;
  387. friend bool operator==(const param_type& x, const param_type& y);
  388. friend bool operator!=(const param_type& x, const param_type& y);
  389. };
  390. // constructors and reset functions
  391. explicit uniform_int_distribution(IntType a = 0,
  392. IntType b = numeric_limits<IntType>::max()); // before C++20
  393. uniform_int_distribution() : uniform_int_distribution(0) {} // C++20
  394. explicit uniform_int_distribution(IntType a,
  395. IntType b = numeric_limits<IntType>::max()); // C++20
  396. explicit uniform_int_distribution(const param_type& parm);
  397. void reset();
  398. // generating functions
  399. template<class URNG> result_type operator()(URNG& g);
  400. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  401. // property functions
  402. result_type a() const;
  403. result_type b() const;
  404. param_type param() const;
  405. void param(const param_type& parm);
  406. result_type min() const;
  407. result_type max() const;
  408. friend bool operator==(const uniform_int_distribution& x,
  409. const uniform_int_distribution& y);
  410. friend bool operator!=(const uniform_int_distribution& x,
  411. const uniform_int_distribution& y);
  412. template <class charT, class traits>
  413. friend
  414. basic_ostream<charT, traits>&
  415. operator<<(basic_ostream<charT, traits>& os,
  416. const uniform_int_distribution& x);
  417. template <class charT, class traits>
  418. friend
  419. basic_istream<charT, traits>&
  420. operator>>(basic_istream<charT, traits>& is,
  421. uniform_int_distribution& x);
  422. };
  423. template<class RealType = double>
  424. class uniform_real_distribution
  425. {
  426. public:
  427. // types
  428. typedef RealType result_type;
  429. class param_type
  430. {
  431. public:
  432. typedef uniform_real_distribution distribution_type;
  433. explicit param_type(RealType a = 0,
  434. RealType b = 1);
  435. result_type a() const;
  436. result_type b() const;
  437. friend bool operator==(const param_type& x, const param_type& y);
  438. friend bool operator!=(const param_type& x, const param_type& y);
  439. };
  440. // constructors and reset functions
  441. explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
  442. uniform_real_distribution() : uniform_real_distribution(0.0) {} // C++20
  443. explicit uniform_real_distribution(RealType a, RealType b = 1.0); // C++20
  444. explicit uniform_real_distribution(const param_type& parm);
  445. void reset();
  446. // generating functions
  447. template<class URNG> result_type operator()(URNG& g);
  448. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  449. // property functions
  450. result_type a() const;
  451. result_type b() const;
  452. param_type param() const;
  453. void param(const param_type& parm);
  454. result_type min() const;
  455. result_type max() const;
  456. friend bool operator==(const uniform_real_distribution& x,
  457. const uniform_real_distribution& y);
  458. friend bool operator!=(const uniform_real_distribution& x,
  459. const uniform_real_distribution& y);
  460. template <class charT, class traits>
  461. friend
  462. basic_ostream<charT, traits>&
  463. operator<<(basic_ostream<charT, traits>& os,
  464. const uniform_real_distribution& x);
  465. template <class charT, class traits>
  466. friend
  467. basic_istream<charT, traits>&
  468. operator>>(basic_istream<charT, traits>& is,
  469. uniform_real_distribution& x);
  470. };
  471. class bernoulli_distribution
  472. {
  473. public:
  474. // types
  475. typedef bool result_type;
  476. class param_type
  477. {
  478. public:
  479. typedef bernoulli_distribution distribution_type;
  480. explicit param_type(double p = 0.5);
  481. double p() const;
  482. friend bool operator==(const param_type& x, const param_type& y);
  483. friend bool operator!=(const param_type& x, const param_type& y);
  484. };
  485. // constructors and reset functions
  486. explicit bernoulli_distribution(double p = 0.5); // before C++20
  487. bernoulli_distribution() : bernoulli_distribution(0.5) {} // C++20
  488. explicit bernoulli_distribution(double p); // C++20
  489. explicit bernoulli_distribution(const param_type& parm);
  490. void reset();
  491. // generating functions
  492. template<class URNG> result_type operator()(URNG& g);
  493. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  494. // property functions
  495. double p() const;
  496. param_type param() const;
  497. void param(const param_type& parm);
  498. result_type min() const;
  499. result_type max() const;
  500. friend bool operator==(const bernoulli_distribution& x,
  501. const bernoulli_distribution& y);
  502. friend bool operator!=(const bernoulli_distribution& x,
  503. const bernoulli_distribution& y);
  504. template <class charT, class traits>
  505. friend
  506. basic_ostream<charT, traits>&
  507. operator<<(basic_ostream<charT, traits>& os,
  508. const bernoulli_distribution& x);
  509. template <class charT, class traits>
  510. friend
  511. basic_istream<charT, traits>&
  512. operator>>(basic_istream<charT, traits>& is,
  513. bernoulli_distribution& x);
  514. };
  515. template<class IntType = int>
  516. class binomial_distribution
  517. {
  518. public:
  519. // types
  520. typedef IntType result_type;
  521. class param_type
  522. {
  523. public:
  524. typedef binomial_distribution distribution_type;
  525. explicit param_type(IntType t = 1, double p = 0.5);
  526. IntType t() const;
  527. double p() const;
  528. friend bool operator==(const param_type& x, const param_type& y);
  529. friend bool operator!=(const param_type& x, const param_type& y);
  530. };
  531. // constructors and reset functions
  532. explicit binomial_distribution(IntType t = 1, double p = 0.5); // before C++20
  533. binomial_distribution() : binomial_distribution(1) {} // C++20
  534. explicit binomial_distribution(IntType t, double p = 0.5); // C++20
  535. explicit binomial_distribution(const param_type& parm);
  536. void reset();
  537. // generating functions
  538. template<class URNG> result_type operator()(URNG& g);
  539. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  540. // property functions
  541. IntType t() const;
  542. double p() const;
  543. param_type param() const;
  544. void param(const param_type& parm);
  545. result_type min() const;
  546. result_type max() const;
  547. friend bool operator==(const binomial_distribution& x,
  548. const binomial_distribution& y);
  549. friend bool operator!=(const binomial_distribution& x,
  550. const binomial_distribution& y);
  551. template <class charT, class traits>
  552. friend
  553. basic_ostream<charT, traits>&
  554. operator<<(basic_ostream<charT, traits>& os,
  555. const binomial_distribution& x);
  556. template <class charT, class traits>
  557. friend
  558. basic_istream<charT, traits>&
  559. operator>>(basic_istream<charT, traits>& is,
  560. binomial_distribution& x);
  561. };
  562. template<class IntType = int>
  563. class geometric_distribution
  564. {
  565. public:
  566. // types
  567. typedef IntType result_type;
  568. class param_type
  569. {
  570. public:
  571. typedef geometric_distribution distribution_type;
  572. explicit param_type(double p = 0.5);
  573. double p() const;
  574. friend bool operator==(const param_type& x, const param_type& y);
  575. friend bool operator!=(const param_type& x, const param_type& y);
  576. };
  577. // constructors and reset functions
  578. explicit geometric_distribution(double p = 0.5); // before C++20
  579. geometric_distribution() : geometric_distribution(0.5) {} // C++20
  580. explicit geometric_distribution(double p); // C++20
  581. explicit geometric_distribution(const param_type& parm);
  582. void reset();
  583. // generating functions
  584. template<class URNG> result_type operator()(URNG& g);
  585. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  586. // property functions
  587. double p() const;
  588. param_type param() const;
  589. void param(const param_type& parm);
  590. result_type min() const;
  591. result_type max() const;
  592. friend bool operator==(const geometric_distribution& x,
  593. const geometric_distribution& y);
  594. friend bool operator!=(const geometric_distribution& x,
  595. const geometric_distribution& y);
  596. template <class charT, class traits>
  597. friend
  598. basic_ostream<charT, traits>&
  599. operator<<(basic_ostream<charT, traits>& os,
  600. const geometric_distribution& x);
  601. template <class charT, class traits>
  602. friend
  603. basic_istream<charT, traits>&
  604. operator>>(basic_istream<charT, traits>& is,
  605. geometric_distribution& x);
  606. };
  607. template<class IntType = int>
  608. class negative_binomial_distribution
  609. {
  610. public:
  611. // types
  612. typedef IntType result_type;
  613. class param_type
  614. {
  615. public:
  616. typedef negative_binomial_distribution distribution_type;
  617. explicit param_type(result_type k = 1, double p = 0.5);
  618. result_type k() const;
  619. double p() const;
  620. friend bool operator==(const param_type& x, const param_type& y);
  621. friend bool operator!=(const param_type& x, const param_type& y);
  622. };
  623. // constructor and reset functions
  624. explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); // before C++20
  625. negative_binomial_distribution() : negative_binomial_distribution(1) {} // C++20
  626. explicit negative_binomial_distribution(IntType k, double p = 0.5); // C++20
  627. explicit negative_binomial_distribution(const param_type& parm);
  628. void reset();
  629. // generating functions
  630. template<class URNG> result_type operator()(URNG& g);
  631. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  632. // property functions
  633. result_type k() const;
  634. double p() const;
  635. param_type param() const;
  636. void param(const param_type& parm);
  637. result_type min() const;
  638. result_type max() const;
  639. friend bool operator==(const negative_binomial_distribution& x,
  640. const negative_binomial_distribution& y);
  641. friend bool operator!=(const negative_binomial_distribution& x,
  642. const negative_binomial_distribution& y);
  643. template <class charT, class traits>
  644. friend
  645. basic_ostream<charT, traits>&
  646. operator<<(basic_ostream<charT, traits>& os,
  647. const negative_binomial_distribution& x);
  648. template <class charT, class traits>
  649. friend
  650. basic_istream<charT, traits>&
  651. operator>>(basic_istream<charT, traits>& is,
  652. negative_binomial_distribution& x);
  653. };
  654. template<class IntType = int>
  655. class poisson_distribution
  656. {
  657. public:
  658. // types
  659. typedef IntType result_type;
  660. class param_type
  661. {
  662. public:
  663. typedef poisson_distribution distribution_type;
  664. explicit param_type(double mean = 1.0);
  665. double mean() const;
  666. friend bool operator==(const param_type& x, const param_type& y);
  667. friend bool operator!=(const param_type& x, const param_type& y);
  668. };
  669. // constructors and reset functions
  670. explicit poisson_distribution(double mean = 1.0); // before C++20
  671. poisson_distribution() : poisson_distribution(1.0) {} // C++20
  672. explicit poisson_distribution(double mean); // C++20
  673. explicit poisson_distribution(const param_type& parm);
  674. void reset();
  675. // generating functions
  676. template<class URNG> result_type operator()(URNG& g);
  677. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  678. // property functions
  679. double mean() const;
  680. param_type param() const;
  681. void param(const param_type& parm);
  682. result_type min() const;
  683. result_type max() const;
  684. friend bool operator==(const poisson_distribution& x,
  685. const poisson_distribution& y);
  686. friend bool operator!=(const poisson_distribution& x,
  687. const poisson_distribution& y);
  688. template <class charT, class traits>
  689. friend
  690. basic_ostream<charT, traits>&
  691. operator<<(basic_ostream<charT, traits>& os,
  692. const poisson_distribution& x);
  693. template <class charT, class traits>
  694. friend
  695. basic_istream<charT, traits>&
  696. operator>>(basic_istream<charT, traits>& is,
  697. poisson_distribution& x);
  698. };
  699. template<class RealType = double>
  700. class exponential_distribution
  701. {
  702. public:
  703. // types
  704. typedef RealType result_type;
  705. class param_type
  706. {
  707. public:
  708. typedef exponential_distribution distribution_type;
  709. explicit param_type(result_type lambda = 1.0);
  710. result_type lambda() const;
  711. friend bool operator==(const param_type& x, const param_type& y);
  712. friend bool operator!=(const param_type& x, const param_type& y);
  713. };
  714. // constructors and reset functions
  715. explicit exponential_distribution(RealType lambda = 1.0); // before C++20
  716. exponential_distribution() : exponential_distribution(1.0) {} // C++20
  717. explicit exponential_distribution(RealType lambda); // C++20
  718. explicit exponential_distribution(const param_type& parm);
  719. void reset();
  720. // generating functions
  721. template<class URNG> result_type operator()(URNG& g);
  722. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  723. // property functions
  724. result_type lambda() const;
  725. param_type param() const;
  726. void param(const param_type& parm);
  727. result_type min() const;
  728. result_type max() const;
  729. friend bool operator==(const exponential_distribution& x,
  730. const exponential_distribution& y);
  731. friend bool operator!=(const exponential_distribution& x,
  732. const exponential_distribution& y);
  733. template <class charT, class traits>
  734. friend
  735. basic_ostream<charT, traits>&
  736. operator<<(basic_ostream<charT, traits>& os,
  737. const exponential_distribution& x);
  738. template <class charT, class traits>
  739. friend
  740. basic_istream<charT, traits>&
  741. operator>>(basic_istream<charT, traits>& is,
  742. exponential_distribution& x);
  743. };
  744. template<class RealType = double>
  745. class gamma_distribution
  746. {
  747. public:
  748. // types
  749. typedef RealType result_type;
  750. class param_type
  751. {
  752. public:
  753. typedef gamma_distribution distribution_type;
  754. explicit param_type(result_type alpha = 1, result_type beta = 1);
  755. result_type alpha() const;
  756. result_type beta() const;
  757. friend bool operator==(const param_type& x, const param_type& y);
  758. friend bool operator!=(const param_type& x, const param_type& y);
  759. };
  760. // constructors and reset functions
  761. explicit gamma_distribution(RealType alpha = 0.0, RealType beta = 1.0); // before C++20
  762. gamma_distribution() : gamma_distribution(0.0) {} // C++20
  763. explicit gamma_distribution(RealType alpha, RealType beta = 1.0); // C++20
  764. explicit gamma_distribution(const param_type& parm);
  765. void reset();
  766. // generating functions
  767. template<class URNG> result_type operator()(URNG& g);
  768. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  769. // property functions
  770. result_type alpha() const;
  771. result_type beta() const;
  772. param_type param() const;
  773. void param(const param_type& parm);
  774. result_type min() const;
  775. result_type max() const;
  776. friend bool operator==(const gamma_distribution& x,
  777. const gamma_distribution& y);
  778. friend bool operator!=(const gamma_distribution& x,
  779. const gamma_distribution& y);
  780. template <class charT, class traits>
  781. friend
  782. basic_ostream<charT, traits>&
  783. operator<<(basic_ostream<charT, traits>& os,
  784. const gamma_distribution& x);
  785. template <class charT, class traits>
  786. friend
  787. basic_istream<charT, traits>&
  788. operator>>(basic_istream<charT, traits>& is,
  789. gamma_distribution& x);
  790. };
  791. template<class RealType = double>
  792. class weibull_distribution
  793. {
  794. public:
  795. // types
  796. typedef RealType result_type;
  797. class param_type
  798. {
  799. public:
  800. typedef weibull_distribution distribution_type;
  801. explicit param_type(result_type alpha = 1, result_type beta = 1);
  802. result_type a() const;
  803. result_type b() const;
  804. friend bool operator==(const param_type& x, const param_type& y);
  805. friend bool operator!=(const param_type& x, const param_type& y);
  806. };
  807. // constructor and reset functions
  808. explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); // before C++20
  809. weibull_distribution() : weibull_distribution(1.0) {} // C++20
  810. explicit weibull_distribution(RealType a, RealType b = 1.0); // C++20
  811. explicit weibull_distribution(const param_type& parm);
  812. void reset();
  813. // generating functions
  814. template<class URNG> result_type operator()(URNG& g);
  815. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  816. // property functions
  817. result_type a() const;
  818. result_type b() const;
  819. param_type param() const;
  820. void param(const param_type& parm);
  821. result_type min() const;
  822. result_type max() const;
  823. friend bool operator==(const weibull_distribution& x,
  824. const weibull_distribution& y);
  825. friend bool operator!=(const weibull_distribution& x,
  826. const weibull_distribution& y);
  827. template <class charT, class traits>
  828. friend
  829. basic_ostream<charT, traits>&
  830. operator<<(basic_ostream<charT, traits>& os,
  831. const weibull_distribution& x);
  832. template <class charT, class traits>
  833. friend
  834. basic_istream<charT, traits>&
  835. operator>>(basic_istream<charT, traits>& is,
  836. weibull_distribution& x);
  837. };
  838. template<class RealType = double>
  839. class extreme_value_distribution
  840. {
  841. public:
  842. // types
  843. typedef RealType result_type;
  844. class param_type
  845. {
  846. public:
  847. typedef extreme_value_distribution distribution_type;
  848. explicit param_type(result_type a = 0, result_type b = 1);
  849. result_type a() const;
  850. result_type b() const;
  851. friend bool operator==(const param_type& x, const param_type& y);
  852. friend bool operator!=(const param_type& x, const param_type& y);
  853. };
  854. // constructor and reset functions
  855. explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
  856. extreme_value_distribution() : extreme_value_distribution(0.0) {} // C++20
  857. explicit extreme_value_distribution(RealType a, RealType b = 1.0); // C++20
  858. explicit extreme_value_distribution(const param_type& parm);
  859. void reset();
  860. // generating functions
  861. template<class URNG> result_type operator()(URNG& g);
  862. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  863. // property functions
  864. result_type a() const;
  865. result_type b() const;
  866. param_type param() const;
  867. void param(const param_type& parm);
  868. result_type min() const;
  869. result_type max() const;
  870. friend bool operator==(const extreme_value_distribution& x,
  871. const extreme_value_distribution& y);
  872. friend bool operator!=(const extreme_value_distribution& x,
  873. const extreme_value_distribution& y);
  874. template <class charT, class traits>
  875. friend
  876. basic_ostream<charT, traits>&
  877. operator<<(basic_ostream<charT, traits>& os,
  878. const extreme_value_distribution& x);
  879. template <class charT, class traits>
  880. friend
  881. basic_istream<charT, traits>&
  882. operator>>(basic_istream<charT, traits>& is,
  883. extreme_value_distribution& x);
  884. };
  885. template<class RealType = double>
  886. class normal_distribution
  887. {
  888. public:
  889. // types
  890. typedef RealType result_type;
  891. class param_type
  892. {
  893. public:
  894. typedef normal_distribution distribution_type;
  895. explicit param_type(result_type mean = 0, result_type stddev = 1);
  896. result_type mean() const;
  897. result_type stddev() const;
  898. friend bool operator==(const param_type& x, const param_type& y);
  899. friend bool operator!=(const param_type& x, const param_type& y);
  900. };
  901. // constructors and reset functions
  902. explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
  903. normal_distribution() : normal_distribution(0.0) {} // C++20
  904. explicit normal_distribution(RealType mean, RealType stddev = 1.0); // C++20
  905. explicit normal_distribution(const param_type& parm);
  906. void reset();
  907. // generating functions
  908. template<class URNG> result_type operator()(URNG& g);
  909. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  910. // property functions
  911. result_type mean() const;
  912. result_type stddev() const;
  913. param_type param() const;
  914. void param(const param_type& parm);
  915. result_type min() const;
  916. result_type max() const;
  917. friend bool operator==(const normal_distribution& x,
  918. const normal_distribution& y);
  919. friend bool operator!=(const normal_distribution& x,
  920. const normal_distribution& y);
  921. template <class charT, class traits>
  922. friend
  923. basic_ostream<charT, traits>&
  924. operator<<(basic_ostream<charT, traits>& os,
  925. const normal_distribution& x);
  926. template <class charT, class traits>
  927. friend
  928. basic_istream<charT, traits>&
  929. operator>>(basic_istream<charT, traits>& is,
  930. normal_distribution& x);
  931. };
  932. template<class RealType = double>
  933. class lognormal_distribution
  934. {
  935. public:
  936. // types
  937. typedef RealType result_type;
  938. class param_type
  939. {
  940. public:
  941. typedef lognormal_distribution distribution_type;
  942. explicit param_type(result_type m = 0, result_type s = 1);
  943. result_type m() const;
  944. result_type s() const;
  945. friend bool operator==(const param_type& x, const param_type& y);
  946. friend bool operator!=(const param_type& x, const param_type& y);
  947. };
  948. // constructor and reset functions
  949. explicit lognormal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20
  950. lognormal_distribution() : lognormal_distribution(0.0) {} // C++20
  951. explicit lognormal_distribution(RealType mean, RealType stddev = 1.0); // C++20
  952. explicit lognormal_distribution(const param_type& parm);
  953. void reset();
  954. // generating functions
  955. template<class URNG> result_type operator()(URNG& g);
  956. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  957. // property functions
  958. result_type m() const;
  959. result_type s() const;
  960. param_type param() const;
  961. void param(const param_type& parm);
  962. result_type min() const;
  963. result_type max() const;
  964. friend bool operator==(const lognormal_distribution& x,
  965. const lognormal_distribution& y);
  966. friend bool operator!=(const lognormal_distribution& x,
  967. const lognormal_distribution& y);
  968. template <class charT, class traits>
  969. friend
  970. basic_ostream<charT, traits>&
  971. operator<<(basic_ostream<charT, traits>& os,
  972. const lognormal_distribution& x);
  973. template <class charT, class traits>
  974. friend
  975. basic_istream<charT, traits>&
  976. operator>>(basic_istream<charT, traits>& is,
  977. lognormal_distribution& x);
  978. };
  979. template<class RealType = double>
  980. class chi_squared_distribution
  981. {
  982. public:
  983. // types
  984. typedef RealType result_type;
  985. class param_type
  986. {
  987. public:
  988. typedef chi_squared_distribution distribution_type;
  989. explicit param_type(result_type n = 1);
  990. result_type n() const;
  991. friend bool operator==(const param_type& x, const param_type& y);
  992. friend bool operator!=(const param_type& x, const param_type& y);
  993. };
  994. // constructor and reset functions
  995. explicit chi_squared_distribution(RealType n = 1.0); // before C++20
  996. chi_squared_distribution() : chi_squared_distribution(1.0) {} // C++20
  997. explicit chi_squared_distribution(RealType n); // C++20
  998. explicit chi_squared_distribution(const param_type& parm);
  999. void reset();
  1000. // generating functions
  1001. template<class URNG> result_type operator()(URNG& g);
  1002. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  1003. // property functions
  1004. result_type n() const;
  1005. param_type param() const;
  1006. void param(const param_type& parm);
  1007. result_type min() const;
  1008. result_type max() const;
  1009. friend bool operator==(const chi_squared_distribution& x,
  1010. const chi_squared_distribution& y);
  1011. friend bool operator!=(const chi_squared_distribution& x,
  1012. const chi_squared_distribution& y);
  1013. template <class charT, class traits>
  1014. friend
  1015. basic_ostream<charT, traits>&
  1016. operator<<(basic_ostream<charT, traits>& os,
  1017. const chi_squared_distribution& x);
  1018. template <class charT, class traits>
  1019. friend
  1020. basic_istream<charT, traits>&
  1021. operator>>(basic_istream<charT, traits>& is,
  1022. chi_squared_distribution& x);
  1023. };
  1024. template<class RealType = double>
  1025. class cauchy_distribution
  1026. {
  1027. public:
  1028. // types
  1029. typedef RealType result_type;
  1030. class param_type
  1031. {
  1032. public:
  1033. typedef cauchy_distribution distribution_type;
  1034. explicit param_type(result_type a = 0, result_type b = 1);
  1035. result_type a() const;
  1036. result_type b() const;
  1037. friend bool operator==(const param_type& x, const param_type& y);
  1038. friend bool operator!=(const param_type& x, const param_type& y);
  1039. };
  1040. // constructor and reset functions
  1041. explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
  1042. cauchy_distribution() : cauchy_distribution(0.0) {} // C++20
  1043. explicit cauchy_distribution(RealType a, RealType b = 1.0); // C++20
  1044. explicit cauchy_distribution(const param_type& parm);
  1045. void reset();
  1046. // generating functions
  1047. template<class URNG> result_type operator()(URNG& g);
  1048. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  1049. // property functions
  1050. result_type a() const;
  1051. result_type b() const;
  1052. param_type param() const;
  1053. void param(const param_type& parm);
  1054. result_type min() const;
  1055. result_type max() const;
  1056. friend bool operator==(const cauchy_distribution& x,
  1057. const cauchy_distribution& y);
  1058. friend bool operator!=(const cauchy_distribution& x,
  1059. const cauchy_distribution& y);
  1060. template <class charT, class traits>
  1061. friend
  1062. basic_ostream<charT, traits>&
  1063. operator<<(basic_ostream<charT, traits>& os,
  1064. const cauchy_distribution& x);
  1065. template <class charT, class traits>
  1066. friend
  1067. basic_istream<charT, traits>&
  1068. operator>>(basic_istream<charT, traits>& is,
  1069. cauchy_distribution& x);
  1070. };
  1071. template<class RealType = double>
  1072. class fisher_f_distribution
  1073. {
  1074. public:
  1075. // types
  1076. typedef RealType result_type;
  1077. class param_type
  1078. {
  1079. public:
  1080. typedef fisher_f_distribution distribution_type;
  1081. explicit param_type(result_type m = 1, result_type n = 1);
  1082. result_type m() const;
  1083. result_type n() const;
  1084. friend bool operator==(const param_type& x, const param_type& y);
  1085. friend bool operator!=(const param_type& x, const param_type& y);
  1086. };
  1087. // constructor and reset functions
  1088. explicit fisher_f_distribution(RealType m = 1.0, RealType n = 1.0); // before C++20
  1089. fisher_f_distribution() : fisher_f_distribution(1.0) {} // C++20
  1090. explicit fisher_f_distribution(RealType m, RealType n = 1.0); // C++20
  1091. explicit fisher_f_distribution(const param_type& parm);
  1092. void reset();
  1093. // generating functions
  1094. template<class URNG> result_type operator()(URNG& g);
  1095. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  1096. // property functions
  1097. result_type m() const;
  1098. result_type n() const;
  1099. param_type param() const;
  1100. void param(const param_type& parm);
  1101. result_type min() const;
  1102. result_type max() const;
  1103. friend bool operator==(const fisher_f_distribution& x,
  1104. const fisher_f_distribution& y);
  1105. friend bool operator!=(const fisher_f_distribution& x,
  1106. const fisher_f_distribution& y);
  1107. template <class charT, class traits>
  1108. friend
  1109. basic_ostream<charT, traits>&
  1110. operator<<(basic_ostream<charT, traits>& os,
  1111. const fisher_f_distribution& x);
  1112. template <class charT, class traits>
  1113. friend
  1114. basic_istream<charT, traits>&
  1115. operator>>(basic_istream<charT, traits>& is,
  1116. fisher_f_distribution& x);
  1117. };
  1118. template<class RealType = double>
  1119. class student_t_distribution
  1120. {
  1121. public:
  1122. // types
  1123. typedef RealType result_type;
  1124. class param_type
  1125. {
  1126. public:
  1127. typedef student_t_distribution distribution_type;
  1128. explicit param_type(result_type n = 1);
  1129. result_type n() const;
  1130. friend bool operator==(const param_type& x, const param_type& y);
  1131. friend bool operator!=(const param_type& x, const param_type& y);
  1132. };
  1133. // constructor and reset functions
  1134. explicit student_t_distribution(RealType n = 1.0); // before C++20
  1135. student_t_distribution() : student_t_distribution(1.0) {} // C++20
  1136. explicit student_t_distribution(RealType n); // C++20
  1137. explicit student_t_distribution(const param_type& parm);
  1138. void reset();
  1139. // generating functions
  1140. template<class URNG> result_type operator()(URNG& g);
  1141. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  1142. // property functions
  1143. result_type n() const;
  1144. param_type param() const;
  1145. void param(const param_type& parm);
  1146. result_type min() const;
  1147. result_type max() const;
  1148. friend bool operator==(const student_t_distribution& x,
  1149. const student_t_distribution& y);
  1150. friend bool operator!=(const student_t_distribution& x,
  1151. const student_t_distribution& y);
  1152. template <class charT, class traits>
  1153. friend
  1154. basic_ostream<charT, traits>&
  1155. operator<<(basic_ostream<charT, traits>& os,
  1156. const student_t_distribution& x);
  1157. template <class charT, class traits>
  1158. friend
  1159. basic_istream<charT, traits>&
  1160. operator>>(basic_istream<charT, traits>& is,
  1161. student_t_distribution& x);
  1162. };
  1163. template<class IntType = int>
  1164. class discrete_distribution
  1165. {
  1166. public:
  1167. // types
  1168. typedef IntType result_type;
  1169. class param_type
  1170. {
  1171. public:
  1172. typedef discrete_distribution distribution_type;
  1173. param_type();
  1174. template<class InputIterator>
  1175. param_type(InputIterator firstW, InputIterator lastW);
  1176. param_type(initializer_list<double> wl);
  1177. template<class UnaryOperation>
  1178. param_type(size_t nw, double xmin, double xmax, UnaryOperation fw);
  1179. vector<double> probabilities() const;
  1180. friend bool operator==(const param_type& x, const param_type& y);
  1181. friend bool operator!=(const param_type& x, const param_type& y);
  1182. };
  1183. // constructor and reset functions
  1184. discrete_distribution();
  1185. template<class InputIterator>
  1186. discrete_distribution(InputIterator firstW, InputIterator lastW);
  1187. discrete_distribution(initializer_list<double> wl);
  1188. template<class UnaryOperation>
  1189. discrete_distribution(size_t nw, double xmin, double xmax,
  1190. UnaryOperation fw);
  1191. explicit discrete_distribution(const param_type& parm);
  1192. void reset();
  1193. // generating functions
  1194. template<class URNG> result_type operator()(URNG& g);
  1195. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  1196. // property functions
  1197. vector<double> probabilities() const;
  1198. param_type param() const;
  1199. void param(const param_type& parm);
  1200. result_type min() const;
  1201. result_type max() const;
  1202. friend bool operator==(const discrete_distribution& x,
  1203. const discrete_distribution& y);
  1204. friend bool operator!=(const discrete_distribution& x,
  1205. const discrete_distribution& y);
  1206. template <class charT, class traits>
  1207. friend
  1208. basic_ostream<charT, traits>&
  1209. operator<<(basic_ostream<charT, traits>& os,
  1210. const discrete_distribution& x);
  1211. template <class charT, class traits>
  1212. friend
  1213. basic_istream<charT, traits>&
  1214. operator>>(basic_istream<charT, traits>& is,
  1215. discrete_distribution& x);
  1216. };
  1217. template<class RealType = double>
  1218. class piecewise_constant_distribution
  1219. {
  1220. // types
  1221. typedef RealType result_type;
  1222. class param_type
  1223. {
  1224. public:
  1225. typedef piecewise_constant_distribution distribution_type;
  1226. param_type();
  1227. template<class InputIteratorB, class InputIteratorW>
  1228. param_type(InputIteratorB firstB, InputIteratorB lastB,
  1229. InputIteratorW firstW);
  1230. template<class UnaryOperation>
  1231. param_type(initializer_list<result_type> bl, UnaryOperation fw);
  1232. template<class UnaryOperation>
  1233. param_type(size_t nw, result_type xmin, result_type xmax,
  1234. UnaryOperation fw);
  1235. vector<result_type> intervals() const;
  1236. vector<result_type> densities() const;
  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. // constructor and reset functions
  1241. piecewise_constant_distribution();
  1242. template<class InputIteratorB, class InputIteratorW>
  1243. piecewise_constant_distribution(InputIteratorB firstB,
  1244. InputIteratorB lastB,
  1245. InputIteratorW firstW);
  1246. template<class UnaryOperation>
  1247. piecewise_constant_distribution(initializer_list<result_type> bl,
  1248. UnaryOperation fw);
  1249. template<class UnaryOperation>
  1250. piecewise_constant_distribution(size_t nw, result_type xmin,
  1251. result_type xmax, UnaryOperation fw);
  1252. explicit piecewise_constant_distribution(const param_type& parm);
  1253. void reset();
  1254. // generating functions
  1255. template<class URNG> result_type operator()(URNG& g);
  1256. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  1257. // property functions
  1258. vector<result_type> intervals() const;
  1259. vector<result_type> densities() const;
  1260. param_type param() const;
  1261. void param(const param_type& parm);
  1262. result_type min() const;
  1263. result_type max() const;
  1264. friend bool operator==(const piecewise_constant_distribution& x,
  1265. const piecewise_constant_distribution& y);
  1266. friend bool operator!=(const piecewise_constant_distribution& x,
  1267. const piecewise_constant_distribution& y);
  1268. template <class charT, class traits>
  1269. friend
  1270. basic_ostream<charT, traits>&
  1271. operator<<(basic_ostream<charT, traits>& os,
  1272. const piecewise_constant_distribution& x);
  1273. template <class charT, class traits>
  1274. friend
  1275. basic_istream<charT, traits>&
  1276. operator>>(basic_istream<charT, traits>& is,
  1277. piecewise_constant_distribution& x);
  1278. };
  1279. template<class RealType = double>
  1280. class piecewise_linear_distribution
  1281. {
  1282. // types
  1283. typedef RealType result_type;
  1284. class param_type
  1285. {
  1286. public:
  1287. typedef piecewise_linear_distribution distribution_type;
  1288. param_type();
  1289. template<class InputIteratorB, class InputIteratorW>
  1290. param_type(InputIteratorB firstB, InputIteratorB lastB,
  1291. InputIteratorW firstW);
  1292. template<class UnaryOperation>
  1293. param_type(initializer_list<result_type> bl, UnaryOperation fw);
  1294. template<class UnaryOperation>
  1295. param_type(size_t nw, result_type xmin, result_type xmax,
  1296. UnaryOperation fw);
  1297. vector<result_type> intervals() const;
  1298. vector<result_type> densities() const;
  1299. friend bool operator==(const param_type& x, const param_type& y);
  1300. friend bool operator!=(const param_type& x, const param_type& y);
  1301. };
  1302. // constructor and reset functions
  1303. piecewise_linear_distribution();
  1304. template<class InputIteratorB, class InputIteratorW>
  1305. piecewise_linear_distribution(InputIteratorB firstB,
  1306. InputIteratorB lastB,
  1307. InputIteratorW firstW);
  1308. template<class UnaryOperation>
  1309. piecewise_linear_distribution(initializer_list<result_type> bl,
  1310. UnaryOperation fw);
  1311. template<class UnaryOperation>
  1312. piecewise_linear_distribution(size_t nw, result_type xmin,
  1313. result_type xmax, UnaryOperation fw);
  1314. explicit piecewise_linear_distribution(const param_type& parm);
  1315. void reset();
  1316. // generating functions
  1317. template<class URNG> result_type operator()(URNG& g);
  1318. template<class URNG> result_type operator()(URNG& g, const param_type& parm);
  1319. // property functions
  1320. vector<result_type> intervals() const;
  1321. vector<result_type> densities() const;
  1322. param_type param() const;
  1323. void param(const param_type& parm);
  1324. result_type min() const;
  1325. result_type max() const;
  1326. friend bool operator==(const piecewise_linear_distribution& x,
  1327. const piecewise_linear_distribution& y);
  1328. friend bool operator!=(const piecewise_linear_distribution& x,
  1329. const piecewise_linear_distribution& y);
  1330. template <class charT, class traits>
  1331. friend
  1332. basic_ostream<charT, traits>&
  1333. operator<<(basic_ostream<charT, traits>& os,
  1334. const piecewise_linear_distribution& x);
  1335. template <class charT, class traits>
  1336. friend
  1337. basic_istream<charT, traits>&
  1338. operator>>(basic_istream<charT, traits>& is,
  1339. piecewise_linear_distribution& x);
  1340. };
  1341. } // std
  1342. */
  1343. #include <__config>
  1344. #include <__random/bernoulli_distribution.h>
  1345. #include <__random/binomial_distribution.h>
  1346. #include <__random/cauchy_distribution.h>
  1347. #include <__random/chi_squared_distribution.h>
  1348. #include <__random/clamp_to_integral.h>
  1349. #include <__random/default_random_engine.h>
  1350. #include <__random/discard_block_engine.h>
  1351. #include <__random/discrete_distribution.h>
  1352. #include <__random/exponential_distribution.h>
  1353. #include <__random/extreme_value_distribution.h>
  1354. #include <__random/fisher_f_distribution.h>
  1355. #include <__random/gamma_distribution.h>
  1356. #include <__random/generate_canonical.h>
  1357. #include <__random/geometric_distribution.h>
  1358. #include <__random/independent_bits_engine.h>
  1359. #include <__random/is_seed_sequence.h>
  1360. #include <__random/knuth_b.h>
  1361. #include <__random/linear_congruential_engine.h>
  1362. #include <__random/log2.h>
  1363. #include <__random/lognormal_distribution.h>
  1364. #include <__random/mersenne_twister_engine.h>
  1365. #include <__random/negative_binomial_distribution.h>
  1366. #include <__random/normal_distribution.h>
  1367. #include <__random/piecewise_constant_distribution.h>
  1368. #include <__random/piecewise_linear_distribution.h>
  1369. #include <__random/poisson_distribution.h>
  1370. #include <__random/random_device.h>
  1371. #include <__random/ranlux.h>
  1372. #include <__random/seed_seq.h>
  1373. #include <__random/shuffle_order_engine.h>
  1374. #include <__random/student_t_distribution.h>
  1375. #include <__random/subtract_with_carry_engine.h>
  1376. #include <__random/uniform_int_distribution.h>
  1377. #include <__random/uniform_random_bit_generator.h>
  1378. #include <__random/uniform_real_distribution.h>
  1379. #include <__random/weibull_distribution.h>
  1380. #include <initializer_list>
  1381. #include <version>
  1382. #include <cmath> // for backward compatibility; TODO remove it
  1383. #include <cstddef> // for backward compatibility; TODO remove it
  1384. #include <cstdint> // for backward compatibility; TODO remove it
  1385. #include <iosfwd> // for backward compatibility; TODO remove it
  1386. #include <limits> // for backward compatibility; TODO remove it
  1387. #include <numeric> // for backward compatibility; TODO remove it
  1388. #include <string> // for backward compatibility; TODO remove it
  1389. #include <type_traits> // for backward compatibility; TODO remove it
  1390. #include <vector> // for backward compatibility; TODO remove it
  1391. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  1392. # pragma GCC system_header
  1393. #endif
  1394. #endif // _LIBCPP_RANDOM