xref: /freebsd/contrib/llvm-project/libcxx/include/random (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
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
10#ifndef _LIBCPP_RANDOM
11#define _LIBCPP_RANDOM
12
13/*
14    random synopsis
15
16#include <initializer_list>
17
18namespace std
19{
20// [rand.req.urng], uniform random bit generator requirements
21template<class G>
22concept uniform_random_bit_generator = see below; // C++20
23
24// Engines
25
26template <class UIntType, UIntType a, UIntType c, UIntType m>
27class linear_congruential_engine
28{
29public:
30    // types
31    typedef UIntType result_type;
32
33    // engine characteristics
34    static constexpr result_type multiplier = a;
35    static constexpr result_type increment = c;
36    static constexpr result_type modulus = m;
37    static constexpr result_type min() { return c == 0u ? 1u: 0u;}
38    static constexpr result_type max() { return m - 1u;}
39    static constexpr result_type default_seed = 1u;
40
41    // constructors and seeding functions
42    explicit linear_congruential_engine(result_type s = default_seed);         // before C++20
43    linear_congruential_engine() : linear_congruential_engine(default_seed) {} // C++20
44    explicit linear_congruential_engine(result_type s);                        // C++20
45    template<class Sseq> explicit linear_congruential_engine(Sseq& q);
46    void seed(result_type s = default_seed);
47    template<class Sseq> void seed(Sseq& q);
48
49    // generating functions
50    result_type operator()();
51    void discard(unsigned long long z);
52};
53
54template <class UIntType, UIntType a, UIntType c, UIntType m>
55bool
56operator==(const linear_congruential_engine<UIntType, a, c, m>& x,
57           const linear_congruential_engine<UIntType, a, c, m>& y);
58
59template <class UIntType, UIntType a, UIntType c, UIntType m>
60bool
61operator!=(const linear_congruential_engine<UIntType, a, c, m>& x,
62           const linear_congruential_engine<UIntType, a, c, m>& y);
63
64template <class charT, class traits,
65          class UIntType, UIntType a, UIntType c, UIntType m>
66basic_ostream<charT, traits>&
67operator<<(basic_ostream<charT, traits>& os,
68           const linear_congruential_engine<UIntType, a, c, m>& x);
69
70template <class charT, class traits,
71          class UIntType, UIntType a, UIntType c, UIntType m>
72basic_istream<charT, traits>&
73operator>>(basic_istream<charT, traits>& is,
74           linear_congruential_engine<UIntType, a, c, m>& x);
75
76template <class UIntType, size_t w, size_t n, size_t m, size_t r,
77          UIntType a, size_t u, UIntType d, size_t s,
78          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
79class mersenne_twister_engine
80{
81public:
82    // types
83    typedef UIntType result_type;
84
85    // engine characteristics
86    static constexpr size_t word_size = w;
87    static constexpr size_t state_size = n;
88    static constexpr size_t shift_size = m;
89    static constexpr size_t mask_bits = r;
90    static constexpr result_type xor_mask = a;
91    static constexpr size_t tempering_u = u;
92    static constexpr result_type tempering_d = d;
93    static constexpr size_t tempering_s = s;
94    static constexpr result_type tempering_b = b;
95    static constexpr size_t tempering_t = t;
96    static constexpr result_type tempering_c = c;
97    static constexpr size_t tempering_l = l;
98    static constexpr result_type initialization_multiplier = f;
99    static constexpr result_type min () { return 0; }
100    static constexpr result_type max() { return 2^w - 1; }
101    static constexpr result_type default_seed = 5489u;
102
103    // constructors and seeding functions
104    explicit mersenne_twister_engine(result_type s = default_seed);      // before C++20
105    mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} // C++20
106    explicit mersenne_twister_engine(result_type s);                     // C++20
107    template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
108    void seed(result_type value = default_seed);
109    template<class Sseq> void seed(Sseq& q);
110
111    // generating functions
112    result_type operator()();
113    void discard(unsigned long long z);
114};
115
116template <class UIntType, size_t w, size_t n, size_t m, size_t r,
117          UIntType a, size_t u, UIntType d, size_t s,
118          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
119bool
120operator==(
121    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
122    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
123
124template <class UIntType, size_t w, size_t n, size_t m, size_t r,
125          UIntType a, size_t u, UIntType d, size_t s,
126          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
127bool
128operator!=(
129    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,
130    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);
131
132template <class charT, class traits,
133          class UIntType, size_t w, size_t n, size_t m, size_t r,
134          UIntType a, size_t u, UIntType d, size_t s,
135          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
136basic_ostream<charT, traits>&
137operator<<(basic_ostream<charT, traits>& os,
138           const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
139
140template <class charT, class traits,
141          class UIntType, size_t w, size_t n, size_t m, size_t r,
142          UIntType a, size_t u, UIntType d, size_t s,
143          UIntType b, size_t t, UIntType c, size_t l, UIntType f>
144basic_istream<charT, traits>&
145operator>>(basic_istream<charT, traits>& is,
146           mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
147
148template<class UIntType, size_t w, size_t s, size_t r>
149class subtract_with_carry_engine
150{
151public:
152    // types
153    typedef UIntType result_type;
154
155    // engine characteristics
156    static constexpr size_t word_size = w;
157    static constexpr size_t short_lag = s;
158    static constexpr size_t long_lag = r;
159    static constexpr result_type min() { return 0; }
160    static constexpr result_type max() { return m-1; }
161    static constexpr result_type default_seed = 19780503u;
162
163    // constructors and seeding functions
164    explicit subtract_with_carry_engine(result_type value = default_seed);     // before C++20
165    subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} // C++20
166    explicit subtract_with_carry_engine(result_type value);                    // C++20
167    template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
168    void seed(result_type value = default_seed);
169    template<class Sseq> void seed(Sseq& q);
170
171    // generating functions
172    result_type operator()();
173    void discard(unsigned long long z);
174};
175
176template<class UIntType, size_t w, size_t s, size_t r>
177bool
178operator==(
179    const subtract_with_carry_engine<UIntType, w, s, r>& x,
180    const subtract_with_carry_engine<UIntType, w, s, r>& y);
181
182template<class UIntType, size_t w, size_t s, size_t r>
183bool
184operator!=(
185    const subtract_with_carry_engine<UIntType, w, s, r>& x,
186    const subtract_with_carry_engine<UIntType, w, s, r>& y);
187
188template <class charT, class traits,
189          class UIntType, size_t w, size_t s, size_t r>
190basic_ostream<charT, traits>&
191operator<<(basic_ostream<charT, traits>& os,
192           const subtract_with_carry_engine<UIntType, w, s, r>& x);
193
194template <class charT, class traits,
195          class UIntType, size_t w, size_t s, size_t r>
196basic_istream<charT, traits>&
197operator>>(basic_istream<charT, traits>& is,
198           subtract_with_carry_engine<UIntType, w, s, r>& x);
199
200template<class Engine, size_t p, size_t r>
201class discard_block_engine
202{
203public:
204    // types
205    typedef typename Engine::result_type result_type;
206
207    // engine characteristics
208    static constexpr size_t block_size = p;
209    static constexpr size_t used_block = r;
210    static constexpr result_type min() { return Engine::min(); }
211    static constexpr result_type max() { return Engine::max(); }
212
213    // constructors and seeding functions
214    discard_block_engine();
215    explicit discard_block_engine(const Engine& e);
216    explicit discard_block_engine(Engine&& e);
217    explicit discard_block_engine(result_type s);
218    template<class Sseq> explicit discard_block_engine(Sseq& q);
219    void seed();
220    void seed(result_type s);
221    template<class Sseq> void seed(Sseq& q);
222
223    // generating functions
224    result_type operator()();
225    void discard(unsigned long long z);
226
227    // property functions
228    const Engine& base() const noexcept;
229};
230
231template<class Engine, size_t p, size_t r>
232bool
233operator==(
234    const discard_block_engine<Engine, p, r>& x,
235    const discard_block_engine<Engine, p, r>& y);
236
237template<class Engine, size_t p, size_t r>
238bool
239operator!=(
240    const discard_block_engine<Engine, p, r>& x,
241    const discard_block_engine<Engine, p, r>& y);
242
243template <class charT, class traits,
244          class Engine, size_t p, size_t r>
245basic_ostream<charT, traits>&
246operator<<(basic_ostream<charT, traits>& os,
247           const discard_block_engine<Engine, p, r>& x);
248
249template <class charT, class traits,
250          class Engine, size_t p, size_t r>
251basic_istream<charT, traits>&
252operator>>(basic_istream<charT, traits>& is,
253           discard_block_engine<Engine, p, r>& x);
254
255template<class Engine, size_t w, class UIntType>
256class independent_bits_engine
257{
258public:
259    // types
260    typedef UIntType result_type;
261
262    // engine characteristics
263    static constexpr result_type min() { return 0; }
264    static constexpr result_type max() { return 2^w - 1; }
265
266    // constructors and seeding functions
267    independent_bits_engine();
268    explicit independent_bits_engine(const Engine& e);
269    explicit independent_bits_engine(Engine&& e);
270    explicit independent_bits_engine(result_type s);
271    template<class Sseq> explicit independent_bits_engine(Sseq& q);
272    void seed();
273    void seed(result_type s);
274    template<class Sseq> void seed(Sseq& q);
275
276    // generating functions
277    result_type operator()(); void discard(unsigned long long z);
278
279    // property functions
280    const Engine& base() const noexcept;
281};
282
283template<class Engine, size_t w, class UIntType>
284bool
285operator==(
286    const independent_bits_engine<Engine, w, UIntType>& x,
287    const independent_bits_engine<Engine, w, UIntType>& y);
288
289template<class Engine, size_t w, class UIntType>
290bool
291operator!=(
292    const independent_bits_engine<Engine, w, UIntType>& x,
293    const independent_bits_engine<Engine, w, UIntType>& y);
294
295template <class charT, class traits,
296          class Engine, size_t w, class UIntType>
297basic_ostream<charT, traits>&
298operator<<(basic_ostream<charT, traits>& os,
299           const independent_bits_engine<Engine, w, UIntType>& x);
300
301template <class charT, class traits,
302          class Engine, size_t w, class UIntType>
303basic_istream<charT, traits>&
304operator>>(basic_istream<charT, traits>& is,
305           independent_bits_engine<Engine, w, UIntType>& x);
306
307template<class Engine, size_t k>
308class shuffle_order_engine
309{
310public:
311    // types
312    typedef typename Engine::result_type result_type;
313
314    // engine characteristics
315    static constexpr size_t table_size = k;
316    static constexpr result_type min() { return Engine::min; }
317    static constexpr result_type max() { return Engine::max; }
318
319    // constructors and seeding functions
320    shuffle_order_engine();
321    explicit shuffle_order_engine(const Engine& e);
322    explicit shuffle_order_engine(Engine&& e);
323    explicit shuffle_order_engine(result_type s);
324    template<class Sseq> explicit shuffle_order_engine(Sseq& q);
325    void seed();
326    void seed(result_type s);
327    template<class Sseq> void seed(Sseq& q);
328
329    // generating functions
330    result_type operator()();
331    void discard(unsigned long long z);
332
333    // property functions
334    const Engine& base() const noexcept;
335};
336
337template<class Engine, size_t k>
338bool
339operator==(
340    const shuffle_order_engine<Engine, k>& x,
341    const shuffle_order_engine<Engine, k>& y);
342
343template<class Engine, size_t k>
344bool
345operator!=(
346    const shuffle_order_engine<Engine, k>& x,
347    const shuffle_order_engine<Engine, k>& y);
348
349template <class charT, class traits,
350          class Engine, size_t k>
351basic_ostream<charT, traits>&
352operator<<(basic_ostream<charT, traits>& os,
353           const shuffle_order_engine<Engine, k>& x);
354
355template <class charT, class traits,
356          class Engine, size_t k>
357basic_istream<charT, traits>&
358operator>>(basic_istream<charT, traits>& is,
359           shuffle_order_engine<Engine, k>& x);
360
361typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
362                                                                   minstd_rand0;
363typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
364                                                                    minstd_rand;
365typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,
366                                0x9908b0df,
367                                11, 0xffffffff,
368                                7,  0x9d2c5680,
369                                15, 0xefc60000,
370                                18, 1812433253>                         mt19937;
371typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,
372                                0xb5026f5aa96619e9,
373                                29, 0x5555555555555555,
374                                17, 0x71d67fffeda60000,
375                                37, 0xfff7eee000000000,
376                                43, 6364136223846793005>             mt19937_64;
377typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>     ranlux24_base;
378typedef subtract_with_carry_engine<uint_fast64_t, 48,  5, 12>     ranlux48_base;
379typedef discard_block_engine<ranlux24_base, 223, 23>                   ranlux24;
380typedef discard_block_engine<ranlux48_base, 389, 11>                   ranlux48;
381typedef shuffle_order_engine<minstd_rand0, 256>                         knuth_b;
382typedef minstd_rand                                       default_random_engine;
383
384// Generators
385
386class random_device
387{
388public:
389    // types
390    typedef unsigned int result_type;
391
392    // generator characteristics
393    static constexpr result_type min() { return numeric_limits<result_type>::min(); }
394    static constexpr result_type max() { return numeric_limits<result_type>::max(); }
395
396    // constructors
397    explicit random_device(const string& token = implementation-defined); // before C++20
398    random_device() : random_device(implementation-defined) {}            // C++20
399    explicit random_device(const string& token);                          // C++20
400
401    // generating functions
402    result_type operator()();
403
404    // property functions
405    double entropy() const noexcept;
406
407    // no copy functions
408    random_device(const random_device& ) = delete;
409    void operator=(const random_device& ) = delete;
410};
411
412// Utilities
413
414class seed_seq
415{
416public:
417    // types
418    typedef uint_least32_t result_type;
419
420    // constructors
421    seed_seq();
422    template<class T>
423        seed_seq(initializer_list<T> il);
424    template<class InputIterator>
425        seed_seq(InputIterator begin, InputIterator end);
426
427    // generating functions
428    template<class RandomAccessIterator>
429        void generate(RandomAccessIterator begin, RandomAccessIterator end);
430
431    // property functions
432    size_t size() const;
433    template<class OutputIterator>
434        void param(OutputIterator dest) const;
435
436    // no copy functions
437    seed_seq(const seed_seq&) = delete;
438    void operator=(const seed_seq& ) = delete;
439};
440
441template<class RealType, size_t bits, class URNG>
442    RealType generate_canonical(URNG& g);
443
444// Distributions
445
446template<class IntType = int>
447class uniform_int_distribution
448{
449public:
450    // types
451    typedef IntType result_type;
452
453    class param_type
454    {
455    public:
456        typedef uniform_int_distribution distribution_type;
457
458        explicit param_type(IntType a = 0,
459                                    IntType b = numeric_limits<IntType>::max());
460
461        result_type a() const;
462        result_type b() const;
463
464        friend bool operator==(const param_type& x, const param_type& y);
465        friend bool operator!=(const param_type& x, const param_type& y);
466    };
467
468    // constructors and reset functions
469    explicit uniform_int_distribution(IntType a = 0,
470                                      IntType b = numeric_limits<IntType>::max()); // before C++20
471    uniform_int_distribution() : uniform_int_distribution(0) {}                    // C++20
472    explicit uniform_int_distribution(IntType a,
473                                      IntType b = numeric_limits<IntType>::max()); // C++20
474    explicit uniform_int_distribution(const param_type& parm);
475    void reset();
476
477    // generating functions
478    template<class URNG> result_type operator()(URNG& g);
479    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
480
481    // property functions
482    result_type a() const;
483    result_type b() const;
484
485    param_type param() const;
486    void param(const param_type& parm);
487
488    result_type min() const;
489    result_type max() const;
490
491    friend bool operator==(const uniform_int_distribution& x,
492                           const uniform_int_distribution& y);
493    friend bool operator!=(const uniform_int_distribution& x,
494                           const uniform_int_distribution& y);
495
496    template <class charT, class traits>
497    friend
498    basic_ostream<charT, traits>&
499    operator<<(basic_ostream<charT, traits>& os,
500               const uniform_int_distribution& x);
501
502    template <class charT, class traits>
503    friend
504    basic_istream<charT, traits>&
505    operator>>(basic_istream<charT, traits>& is,
506               uniform_int_distribution& x);
507};
508
509template<class RealType = double>
510class uniform_real_distribution
511{
512public:
513    // types
514    typedef RealType result_type;
515
516    class param_type
517    {
518    public:
519        typedef uniform_real_distribution distribution_type;
520
521        explicit param_type(RealType a = 0,
522                            RealType b = 1);
523
524        result_type a() const;
525        result_type b() const;
526
527        friend bool operator==(const param_type& x, const param_type& y);
528        friend bool operator!=(const param_type& x, const param_type& y);
529    };
530
531    // constructors and reset functions
532    explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20
533    uniform_real_distribution() : uniform_real_distribution(0.0) {}         // C++20
534    explicit uniform_real_distribution(RealType a, RealType b = 1.0);       // C++20
535    explicit uniform_real_distribution(const param_type& parm);
536    void reset();
537
538    // generating functions
539    template<class URNG> result_type operator()(URNG& g);
540    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
541
542    // property functions
543    result_type a() const;
544    result_type b() const;
545
546    param_type param() const;
547    void param(const param_type& parm);
548
549    result_type min() const;
550    result_type max() const;
551
552    friend bool operator==(const uniform_real_distribution& x,
553                           const uniform_real_distribution& y);
554    friend bool operator!=(const uniform_real_distribution& x,
555                           const uniform_real_distribution& y);
556
557    template <class charT, class traits>
558    friend
559    basic_ostream<charT, traits>&
560    operator<<(basic_ostream<charT, traits>& os,
561               const uniform_real_distribution& x);
562
563    template <class charT, class traits>
564    friend
565    basic_istream<charT, traits>&
566    operator>>(basic_istream<charT, traits>& is,
567               uniform_real_distribution& x);
568};
569
570class bernoulli_distribution
571{
572public:
573    // types
574    typedef bool result_type;
575
576    class param_type
577    {
578    public:
579        typedef bernoulli_distribution distribution_type;
580
581        explicit param_type(double p = 0.5);
582
583        double p() const;
584
585        friend bool operator==(const param_type& x, const param_type& y);
586        friend bool operator!=(const param_type& x, const param_type& y);
587    };
588
589    // constructors and reset functions
590    explicit bernoulli_distribution(double p = 0.5);          // before C++20
591    bernoulli_distribution() : bernoulli_distribution(0.5) {} // C++20
592    explicit bernoulli_distribution(double p);                // C++20
593    explicit bernoulli_distribution(const param_type& parm);
594    void reset();
595
596    // generating functions
597    template<class URNG> result_type operator()(URNG& g);
598    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
599
600    // property functions
601    double p() const;
602
603    param_type param() const;
604    void param(const param_type& parm);
605
606    result_type min() const;
607    result_type max() const;
608
609    friend bool operator==(const bernoulli_distribution& x,
610                           const bernoulli_distribution& y);
611    friend bool operator!=(const bernoulli_distribution& x,
612                           const bernoulli_distribution& y);
613
614    template <class charT, class traits>
615    friend
616    basic_ostream<charT, traits>&
617    operator<<(basic_ostream<charT, traits>& os,
618               const bernoulli_distribution& x);
619
620    template <class charT, class traits>
621    friend
622    basic_istream<charT, traits>&
623    operator>>(basic_istream<charT, traits>& is,
624               bernoulli_distribution& x);
625};
626
627template<class IntType = int>
628class binomial_distribution
629{
630public:
631    // types
632    typedef IntType result_type;
633
634    class param_type
635    {
636    public:
637        typedef binomial_distribution distribution_type;
638
639        explicit param_type(IntType t = 1, double p = 0.5);
640
641        IntType t() const;
642        double p() const;
643
644        friend bool operator==(const param_type& x, const param_type& y);
645        friend bool operator!=(const param_type& x, const param_type& y);
646    };
647
648    // constructors and reset functions
649    explicit binomial_distribution(IntType t = 1, double p = 0.5); // before C++20
650    binomial_distribution() : binomial_distribution(1) {}          // C++20
651    explicit binomial_distribution(IntType t, double p = 0.5);     // C++20
652    explicit binomial_distribution(const param_type& parm);
653    void reset();
654
655    // generating functions
656    template<class URNG> result_type operator()(URNG& g);
657    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
658
659    // property functions
660    IntType t() const;
661    double p() const;
662
663    param_type param() const;
664    void param(const param_type& parm);
665
666    result_type min() const;
667    result_type max() const;
668
669    friend bool operator==(const binomial_distribution& x,
670                           const binomial_distribution& y);
671    friend bool operator!=(const binomial_distribution& x,
672                           const binomial_distribution& y);
673
674    template <class charT, class traits>
675    friend
676    basic_ostream<charT, traits>&
677    operator<<(basic_ostream<charT, traits>& os,
678               const binomial_distribution& x);
679
680    template <class charT, class traits>
681    friend
682    basic_istream<charT, traits>&
683    operator>>(basic_istream<charT, traits>& is,
684               binomial_distribution& x);
685};
686
687template<class IntType = int>
688class geometric_distribution
689{
690public:
691    // types
692    typedef IntType result_type;
693
694    class param_type
695    {
696    public:
697        typedef geometric_distribution distribution_type;
698
699        explicit param_type(double p = 0.5);
700
701        double p() const;
702
703        friend bool operator==(const param_type& x, const param_type& y);
704        friend bool operator!=(const param_type& x, const param_type& y);
705    };
706
707    // constructors and reset functions
708    explicit geometric_distribution(double p = 0.5);          // before C++20
709    geometric_distribution() : geometric_distribution(0.5) {} // C++20
710    explicit geometric_distribution(double p);                // C++20
711    explicit geometric_distribution(const param_type& parm);
712    void reset();
713
714    // generating functions
715    template<class URNG> result_type operator()(URNG& g);
716    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
717
718    // property functions
719    double p() const;
720
721    param_type param() const;
722    void param(const param_type& parm);
723
724    result_type min() const;
725    result_type max() const;
726
727    friend bool operator==(const geometric_distribution& x,
728                           const geometric_distribution& y);
729    friend bool operator!=(const geometric_distribution& x,
730                           const geometric_distribution& y);
731
732    template <class charT, class traits>
733    friend
734    basic_ostream<charT, traits>&
735    operator<<(basic_ostream<charT, traits>& os,
736               const geometric_distribution& x);
737
738    template <class charT, class traits>
739    friend
740    basic_istream<charT, traits>&
741    operator>>(basic_istream<charT, traits>& is,
742               geometric_distribution& x);
743};
744
745template<class IntType = int>
746class negative_binomial_distribution
747{
748public:
749    // types
750    typedef IntType result_type;
751
752    class param_type
753    {
754    public:
755        typedef negative_binomial_distribution distribution_type;
756
757        explicit param_type(result_type k = 1, double p = 0.5);
758
759        result_type k() const;
760        double p() const;
761
762        friend bool operator==(const param_type& x, const param_type& y);
763        friend bool operator!=(const param_type& x, const param_type& y);
764    };
765
766    // constructor and reset functions
767    explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); // before C++20
768    negative_binomial_distribution() : negative_binomial_distribution(1) {} // C++20
769    explicit negative_binomial_distribution(IntType k, double p = 0.5);     // C++20
770    explicit negative_binomial_distribution(const param_type& parm);
771    void reset();
772
773    // generating functions
774    template<class URNG> result_type operator()(URNG& g);
775    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
776
777    // property functions
778    result_type k() const;
779    double p() const;
780
781    param_type param() const;
782    void param(const param_type& parm);
783
784    result_type min() const;
785    result_type max() const;
786
787    friend bool operator==(const negative_binomial_distribution& x,
788                           const negative_binomial_distribution& y);
789    friend bool operator!=(const negative_binomial_distribution& x,
790                           const negative_binomial_distribution& y);
791
792    template <class charT, class traits>
793    friend
794    basic_ostream<charT, traits>&
795    operator<<(basic_ostream<charT, traits>& os,
796               const negative_binomial_distribution& x);
797
798    template <class charT, class traits>
799    friend
800    basic_istream<charT, traits>&
801    operator>>(basic_istream<charT, traits>& is,
802               negative_binomial_distribution& x);
803};
804
805template<class IntType = int>
806class poisson_distribution
807{
808public:
809    // types
810    typedef IntType result_type;
811
812    class param_type
813    {
814    public:
815        typedef poisson_distribution distribution_type;
816
817        explicit param_type(double mean = 1.0);
818
819        double mean() const;
820
821        friend bool operator==(const param_type& x, const param_type& y);
822        friend bool operator!=(const param_type& x, const param_type& y);
823    };
824
825    // constructors and reset functions
826    explicit poisson_distribution(double mean = 1.0);     // before C++20
827    poisson_distribution() : poisson_distribution(1.0) {} // C++20
828    explicit poisson_distribution(double mean);           // C++20
829    explicit poisson_distribution(const param_type& parm);
830    void reset();
831
832    // generating functions
833    template<class URNG> result_type operator()(URNG& g);
834    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
835
836    // property functions
837    double mean() const;
838
839    param_type param() const;
840    void param(const param_type& parm);
841
842    result_type min() const;
843    result_type max() const;
844
845    friend bool operator==(const poisson_distribution& x,
846                           const poisson_distribution& y);
847    friend bool operator!=(const poisson_distribution& x,
848                           const poisson_distribution& y);
849
850    template <class charT, class traits>
851    friend
852    basic_ostream<charT, traits>&
853    operator<<(basic_ostream<charT, traits>& os,
854               const poisson_distribution& x);
855
856    template <class charT, class traits>
857    friend
858    basic_istream<charT, traits>&
859    operator>>(basic_istream<charT, traits>& is,
860               poisson_distribution& x);
861};
862
863template<class RealType = double>
864class exponential_distribution
865{
866public:
867    // types
868    typedef RealType result_type;
869
870    class param_type
871    {
872    public:
873        typedef exponential_distribution distribution_type;
874
875        explicit param_type(result_type lambda = 1.0);
876
877        result_type lambda() const;
878
879        friend bool operator==(const param_type& x, const param_type& y);
880        friend bool operator!=(const param_type& x, const param_type& y);
881    };
882
883    // constructors and reset functions
884    explicit exponential_distribution(RealType lambda = 1.0);     // before C++20
885    exponential_distribution() : exponential_distribution(1.0) {} // C++20
886    explicit exponential_distribution(RealType lambda);           // C++20
887    explicit exponential_distribution(const param_type& parm);
888    void reset();
889
890    // generating functions
891    template<class URNG> result_type operator()(URNG& g);
892    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
893
894    // property functions
895    result_type lambda() const;
896
897    param_type param() const;
898    void param(const param_type& parm);
899
900    result_type min() const;
901    result_type max() const;
902
903    friend bool operator==(const exponential_distribution& x,
904                           const exponential_distribution& y);
905    friend bool operator!=(const exponential_distribution& x,
906                           const exponential_distribution& y);
907
908    template <class charT, class traits>
909    friend
910    basic_ostream<charT, traits>&
911    operator<<(basic_ostream<charT, traits>& os,
912               const exponential_distribution& x);
913
914    template <class charT, class traits>
915    friend
916    basic_istream<charT, traits>&
917    operator>>(basic_istream<charT, traits>& is,
918               exponential_distribution& x);
919};
920
921template<class RealType = double>
922class gamma_distribution
923{
924public:
925    // types
926    typedef RealType result_type;
927
928    class param_type
929    {
930    public:
931        typedef gamma_distribution distribution_type;
932
933        explicit param_type(result_type alpha = 1, result_type beta = 1);
934
935        result_type alpha() const;
936        result_type beta() const;
937
938        friend bool operator==(const param_type& x, const param_type& y);
939        friend bool operator!=(const param_type& x, const param_type& y);
940    };
941
942    // constructors and reset functions
943    explicit gamma_distribution(RealType alpha = 0.0, RealType beta = 1.0); // before C++20
944    gamma_distribution() : gamma_distribution(0.0) {}                       // C++20
945    explicit gamma_distribution(RealType alpha, RealType beta = 1.0);       // C++20
946    explicit gamma_distribution(const param_type& parm);
947    void reset();
948
949    // generating functions
950    template<class URNG> result_type operator()(URNG& g);
951    template<class URNG> result_type operator()(URNG& g, const param_type& parm);
952
953    // property functions
954    result_type alpha() const;
955    result_type beta() const;
956
957    param_type param() const;
958    void param(const param_type& parm);
959
960    result_type min() const;
961    result_type max() const;
962
963    friend bool operator==(const gamma_distribution& x,
964                           const gamma_distribution& y);
965    friend bool operator!=(const gamma_distribution& x,
966                           const gamma_distribution& y);
967
968    template <class charT, class traits>
969    friend
970    basic_ostream<charT, traits>&
971    operator<<(basic_ostream<charT, traits>& os,
972               const gamma_distribution& x);
973
974    template <class charT, class traits>
975    friend
976    basic_istream<charT, traits>&
977    operator>>(basic_istream<charT, traits>& is,
978               gamma_distribution& x);
979};
980
981template<class RealType = double>
982class weibull_distribution
983{
984public:
985    // types
986    typedef RealType result_type;
987
988    class param_type
989    {
990    public:
991        typedef weibull_distribution distribution_type;
992
993        explicit param_type(result_type alpha = 1, result_type beta = 1);
994
995        result_type a() const;
996        result_type b() const;
997
998        friend bool operator==(const param_type& x, const param_type& y);
999        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
1041template<class RealType = double>
1042class extreme_value_distribution
1043{
1044public:
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
1101template<class RealType = double>
1102class normal_distribution
1103{
1104public:
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
1161template<class RealType = double>
1162class lognormal_distribution
1163{
1164public:
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
1221template<class RealType = double>
1222class chi_squared_distribution
1223{
1224public:
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
1279template<class RealType = double>
1280class cauchy_distribution
1281{
1282public:
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
1339template<class RealType = double>
1340class fisher_f_distribution
1341{
1342public:
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
1399template<class RealType = double>
1400class student_t_distribution
1401{
1402public:
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
1457template<class IntType = int>
1458class discrete_distribution
1459{
1460public:
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
1524template<class RealType = double>
1525class 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
1599template<class RealType = double>
1600class 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#include <__assert> // all public C++ headers provide the assertion handler
1681#include <__config>
1682#include <__random/bernoulli_distribution.h>
1683#include <__random/binomial_distribution.h>
1684#include <__random/cauchy_distribution.h>
1685#include <__random/chi_squared_distribution.h>
1686#include <__random/clamp_to_integral.h>
1687#include <__random/default_random_engine.h>
1688#include <__random/discard_block_engine.h>
1689#include <__random/discrete_distribution.h>
1690#include <__random/exponential_distribution.h>
1691#include <__random/extreme_value_distribution.h>
1692#include <__random/fisher_f_distribution.h>
1693#include <__random/gamma_distribution.h>
1694#include <__random/generate_canonical.h>
1695#include <__random/geometric_distribution.h>
1696#include <__random/independent_bits_engine.h>
1697#include <__random/is_seed_sequence.h>
1698#include <__random/is_valid.h>
1699#include <__random/knuth_b.h>
1700#include <__random/linear_congruential_engine.h>
1701#include <__random/log2.h>
1702#include <__random/lognormal_distribution.h>
1703#include <__random/mersenne_twister_engine.h>
1704#include <__random/negative_binomial_distribution.h>
1705#include <__random/normal_distribution.h>
1706#include <__random/piecewise_constant_distribution.h>
1707#include <__random/piecewise_linear_distribution.h>
1708#include <__random/poisson_distribution.h>
1709#include <__random/random_device.h>
1710#include <__random/ranlux.h>
1711#include <__random/seed_seq.h>
1712#include <__random/shuffle_order_engine.h>
1713#include <__random/student_t_distribution.h>
1714#include <__random/subtract_with_carry_engine.h>
1715#include <__random/uniform_int_distribution.h>
1716#include <__random/uniform_random_bit_generator.h>
1717#include <__random/uniform_real_distribution.h>
1718#include <__random/weibull_distribution.h>
1719#include <version>
1720
1721// standard-mandated includes
1722
1723// [rand.synopsis]
1724#include <initializer_list>
1725
1726#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1727#  pragma GCC system_header
1728#endif
1729
1730#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1731#  include <algorithm>
1732#  include <climits>
1733#  include <cmath>
1734#  include <concepts>
1735#  include <cstddef>
1736#  include <cstdint>
1737#  include <cstdlib>
1738#  include <iosfwd>
1739#  include <limits>
1740#  include <numeric>
1741#  include <string>
1742#  include <type_traits>
1743#  include <vector>
1744#endif
1745
1746#endif // _LIBCPP_RANDOM
1747