Files
2025-10-25 03:02:53 +03:00

13 lines
9.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.2Header <initializer_­list> synopsis")namespace std {// [[rand.req.urng]](rand.req.urng "29.5.3.3Uniform 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.2Class 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.3Class 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.4Class 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.2Class 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.3Class 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.4Class 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.5Class 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.6Engines 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.7Class random_­device"), class random_deviceclass random_device; // [[rand.util.seedseq]](rand.util.seedseq "29.5.8.1Class seed_­seq"), class seed_seqclass seed_seq; // [[rand.util.canonical]](rand.util.canonical "29.5.8.2Function 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.2generate_­random"), generate_randomtemplate<class R, class G>requires [output_range](range.refinements#concept:output_range "25.4.6Other range refinements[range.refinements]")<R, invoke_result_t<G&>> &&[uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3Uniform 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.10Concept output_­iterator[iterator.concept.output]")<invoke_result_t<G&>> O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7Concept sentinel_­for[iterator.concept.sentinel]")<O> S>requires [uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3Uniform 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.6Other range refinements[range.refinements]")<R, invoke_result_t<D&, G&>> && [invocable](concept.invocable#concept:invocable "18.7.2Concept invocable[concept.invocable]")<D&, G&> &&[uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3Uniform 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.10Concept output_­iterator[iterator.concept.output]")<invoke_result_t<D&, G&>> O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7Concept sentinel_­for[iterator.concept.sentinel]")<O> S>requires [invocable](concept.invocable#concept:invocable "18.7.2Concept invocable[concept.invocable]")<D&, G&> && [uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3Uniform 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.1Class 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.2Class 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.1Class bernoulli_­distribution"), class bernoulli_distributionclass bernoulli_distribution; // [[rand.dist.bern.bin]](rand.dist.bern.bin "29.5.9.3.2Class 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.3Class 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.4Class 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.1Class 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.2Class 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.3Class 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.4Class 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.5Class 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.1Class 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.2Class 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.3Class 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.4Class 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.5Class 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.6Class 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.1Class 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.2Class 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.3Class template piecewise_­linear_­distribution"), class template piecewise_linear_distributiontemplate<class RealType = double>class piecewise_linear_distribution;}