13 lines
9.7 KiB
Markdown
13 lines
9.7 KiB
Markdown
[rand.synopsis]
|
||
|
||
# 29 Numerics library [[numerics]](./#numerics)
|
||
|
||
## 29.5 Random number generation [[rand]](rand#synopsis)
|
||
|
||
### 29.5.2 Header <random> synopsis [rand.synopsis]
|
||
|
||
#include <initializer_list> // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header <initializer_list> synopsis")namespace std {// [[rand.req.urng]](rand.req.urng "29.5.3.3 Uniform random bit generator requirements"), uniform random bit generator requirementstemplate<class G>concept uniform_random_bit_generator = *see below*; // freestanding// [[rand.eng.lcong]](rand.eng.lcong "29.5.4.2 Class template linear_congruential_engine"), class template linear_congruential_enginetemplate<class UIntType, UIntType a, UIntType c, UIntType m>class linear_congruential_engine; // partially freestanding// [[rand.eng.mers]](rand.eng.mers "29.5.4.3 Class template mersenne_twister_engine"), class template mersenne_twister_enginetemplate<class UIntType, size_t w, size_t n, size_t m, size_t r,
|
||
UIntType a, size_t u, UIntType d, size_t s,
|
||
UIntType b, size_t t,
|
||
UIntType c, size_t l, UIntType f>class mersenne_twister_engine; // [[rand.eng.sub]](rand.eng.sub "29.5.4.4 Class template subtract_with_carry_engine"), class template subtract_with_carry_enginetemplate<class UIntType, size_t w, size_t s, size_t r>class subtract_with_carry_engine; // partially freestanding// [[rand.adapt.disc]](rand.adapt.disc "29.5.5.2 Class template discard_block_engine"), class template discard_block_enginetemplate<class Engine, size_t p, size_t r>class discard_block_engine; // partially freestanding// [[rand.adapt.ibits]](rand.adapt.ibits "29.5.5.3 Class template independent_bits_engine"), class template independent_bits_enginetemplate<class Engine, size_t w, class UIntType>class independent_bits_engine; // partially freestanding// [[rand.adapt.shuf]](rand.adapt.shuf "29.5.5.4 Class template shuffle_order_engine"), class template shuffle_order_enginetemplate<class Engine, size_t k>class shuffle_order_engine; // [[rand.eng.philox]](rand.eng.philox "29.5.4.5 Class template philox_engine"), class template philox_enginetemplate<class UIntType, size_t w, size_t n, size_t r, UIntType... consts>class philox_engine; // partially freestanding// [[rand.predef]](rand.predef "29.5.6 Engines and engine adaptors with predefined parameters"), engines and engine adaptors with predefined parametersusing minstd_rand0 = *see below*; // freestandingusing minstd_rand = *see below*; // freestandingusing mt19937 = *see below*; // freestandingusing mt19937_64 = *see below*; // freestandingusing ranlux24_base = *see below*; // freestandingusing ranlux48_base = *see below*; // freestandingusing ranlux24 = *see below*; // freestandingusing ranlux48 = *see below*; // freestandingusing knuth_b = *see below*; using philox4x32 = *see below*; // freestandingusing philox4x64 = *see below*; // freestandingusing default_random_engine = *see below*; // [[rand.device]](rand.device "29.5.7 Class random_device"), class random_deviceclass random_device; // [[rand.util.seedseq]](rand.util.seedseq "29.5.8.1 Class seed_seq"), class seed_seqclass seed_seq; // [[rand.util.canonical]](rand.util.canonical "29.5.8.2 Function template generate_canonical"), function template generate_canonicaltemplate<class RealType, size_t digits, class URBG> RealType generate_canonical(URBG& g); namespace ranges {// [[alg.rand.generate]](alg.rand.generate "26.12.2 generate_random"), generate_randomtemplate<class R, class G>requires [output_range](range.refinements#concept:output_range "25.4.6 Other range refinements [range.refinements]")<R, invoke_result_t<G&>> &&[uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3 Uniform random bit generator requirements [rand.req.urng]")<remove_cvref_t<G>>constexpr borrowed_iterator_t<R> generate_random(R&& r, G&& g); template<class G, [output_iterator](iterator.concept.output#concept:output_iterator "24.3.4.10 Concept output_iterator [iterator.concept.output]")<invoke_result_t<G&>> O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<O> S>requires [uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3 Uniform random bit generator requirements [rand.req.urng]")<remove_cvref_t<G>>constexpr O generate_random(O first, S last, G&& g); template<class R, class G, class D>requires [output_range](range.refinements#concept:output_range "25.4.6 Other range refinements [range.refinements]")<R, invoke_result_t<D&, G&>> && [invocable](concept.invocable#concept:invocable "18.7.2 Concept invocable [concept.invocable]")<D&, G&> &&[uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3 Uniform random bit generator requirements [rand.req.urng]")<remove_cvref_t<G>> && is_arithmetic_v<invoke_result_t<D&, G&>>constexpr borrowed_iterator_t<R> generate_random(R&& r, G&& g, D&& d); template<class G, class D, [output_iterator](iterator.concept.output#concept:output_iterator "24.3.4.10 Concept output_iterator [iterator.concept.output]")<invoke_result_t<D&, G&>> O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_for [iterator.concept.sentinel]")<O> S>requires [invocable](concept.invocable#concept:invocable "18.7.2 Concept invocable [concept.invocable]")<D&, G&> && [uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3 Uniform random bit generator requirements [rand.req.urng]")<remove_cvref_t<G>> && is_arithmetic_v<invoke_result_t<D&, G&>>constexpr O generate_random(O first, S last, G&& g, D&& d); }// [[rand.dist.uni.int]](rand.dist.uni.int "29.5.9.2.1 Class template uniform_int_distribution"), class template uniform_int_distributiontemplate<class IntType = int>class uniform_int_distribution; // partially freestanding// [[rand.dist.uni.real]](rand.dist.uni.real "29.5.9.2.2 Class template uniform_real_distribution"), class template uniform_real_distributiontemplate<class RealType = double>class uniform_real_distribution; // [[rand.dist.bern.bernoulli]](rand.dist.bern.bernoulli "29.5.9.3.1 Class bernoulli_distribution"), class bernoulli_distributionclass bernoulli_distribution; // [[rand.dist.bern.bin]](rand.dist.bern.bin "29.5.9.3.2 Class template binomial_distribution"), class template binomial_distributiontemplate<class IntType = int>class binomial_distribution; // [[rand.dist.bern.geo]](rand.dist.bern.geo "29.5.9.3.3 Class template geometric_distribution"), class template geometric_distributiontemplate<class IntType = int>class geometric_distribution; // [[rand.dist.bern.negbin]](rand.dist.bern.negbin "29.5.9.3.4 Class template negative_binomial_distribution"), class template negative_binomial_distributiontemplate<class IntType = int>class negative_binomial_distribution; // [[rand.dist.pois.poisson]](rand.dist.pois.poisson "29.5.9.4.1 Class template poisson_distribution"), class template poisson_distributiontemplate<class IntType = int>class poisson_distribution; // [[rand.dist.pois.exp]](rand.dist.pois.exp "29.5.9.4.2 Class template exponential_distribution"), class template exponential_distributiontemplate<class RealType = double>class exponential_distribution; // [[rand.dist.pois.gamma]](rand.dist.pois.gamma "29.5.9.4.3 Class template gamma_distribution"), class template gamma_distributiontemplate<class RealType = double>class gamma_distribution; // [[rand.dist.pois.weibull]](rand.dist.pois.weibull "29.5.9.4.4 Class template weibull_distribution"), class template weibull_distributiontemplate<class RealType = double>class weibull_distribution; // [[rand.dist.pois.extreme]](rand.dist.pois.extreme "29.5.9.4.5 Class template extreme_value_distribution"), class template extreme_value_distributiontemplate<class RealType = double>class extreme_value_distribution; // [[rand.dist.norm.normal]](rand.dist.norm.normal "29.5.9.5.1 Class template normal_distribution"), class template normal_distributiontemplate<class RealType = double>class normal_distribution; // [[rand.dist.norm.lognormal]](rand.dist.norm.lognormal "29.5.9.5.2 Class template lognormal_distribution"), class template lognormal_distributiontemplate<class RealType = double>class lognormal_distribution; // [[rand.dist.norm.chisq]](rand.dist.norm.chisq "29.5.9.5.3 Class template chi_squared_distribution"), class template chi_squared_distributiontemplate<class RealType = double>class chi_squared_distribution; // [[rand.dist.norm.cauchy]](rand.dist.norm.cauchy "29.5.9.5.4 Class template cauchy_distribution"), class template cauchy_distributiontemplate<class RealType = double>class cauchy_distribution; // [[rand.dist.norm.f]](rand.dist.norm.f "29.5.9.5.5 Class template fisher_f_distribution"), class template fisher_f_distributiontemplate<class RealType = double>class fisher_f_distribution; // [[rand.dist.norm.t]](rand.dist.norm.t "29.5.9.5.6 Class template student_t_distribution"), class template student_t_distributiontemplate<class RealType = double>class student_t_distribution; // [[rand.dist.samp.discrete]](rand.dist.samp.discrete "29.5.9.6.1 Class template discrete_distribution"), class template discrete_distributiontemplate<class IntType = int>class discrete_distribution; // [[rand.dist.samp.pconst]](rand.dist.samp.pconst "29.5.9.6.2 Class template piecewise_constant_distribution"), class template piecewise_constant_distributiontemplate<class RealType = double>class piecewise_constant_distribution; // [[rand.dist.samp.plinear]](rand.dist.samp.plinear "29.5.9.6.3 Class template piecewise_linear_distribution"), class template piecewise_linear_distributiontemplate<class RealType = double>class piecewise_linear_distribution;}
|