[rand.synopsis] # 29 Numerics library [[numerics]](./#numerics) ## 29.5 Random number generation [[rand]](rand#synopsis) ### 29.5.2 Header synopsis [rand.synopsis] #include // see [[initializer.list.syn]](initializer.list.syn "17.11.2 Header synopsis")namespace std {// [[rand.req.urng]](rand.req.urng "29.5.3.3 Uniform random bit generator requirements"), uniform random bit generator requirementstemplateconcept 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_enginetemplateclass linear_congruential_engine; // partially freestanding// [[rand.eng.mers]](rand.eng.mers "29.5.4.3 Class template mersenne_­twister_­engine"), class template mersenne_twister_enginetemplateclass mersenne_twister_engine; // [[rand.eng.sub]](rand.eng.sub "29.5.4.4 Class template subtract_­with_­carry_­engine"), class template subtract_with_carry_enginetemplateclass 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_enginetemplateclass discard_block_engine; // partially freestanding// [[rand.adapt.ibits]](rand.adapt.ibits "29.5.5.3 Class template independent_­bits_­engine"), class template independent_bits_enginetemplateclass independent_bits_engine; // partially freestanding// [[rand.adapt.shuf]](rand.adapt.shuf "29.5.5.4 Class template shuffle_­order_­engine"), class template shuffle_order_enginetemplateclass shuffle_order_engine; // [[rand.eng.philox]](rand.eng.philox "29.5.4.5 Class template philox_­engine"), class template philox_enginetemplateclass 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 RealType generate_canonical(URBG& g); namespace ranges {// [[alg.rand.generate]](alg.rand.generate "26.12.2 generate_­random"), generate_randomtemplaterequires [output_range](range.refinements#concept:output_range "25.4.6 Other range refinements [range.refinements]")> &&[uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3 Uniform random bit generator requirements [rand.req.urng]")>constexpr borrowed_iterator_t generate_random(R&& r, G&& g); template> O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]") 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]")>constexpr O generate_random(O first, S last, G&& g); templaterequires [output_range](range.refinements#concept:output_range "25.4.6 Other range refinements [range.refinements]")> && [invocable](concept.invocable#concept:invocable "18.7.2 Concept invocable [concept.invocable]") &&[uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3 Uniform random bit generator requirements [rand.req.urng]")> && is_arithmetic_v>constexpr borrowed_iterator_t generate_random(R&& r, G&& g, D&& d); template> O, [sentinel_for](iterator.concept.sentinel#concept:sentinel_for "24.3.4.7 Concept sentinel_­for [iterator.concept.sentinel]") S>requires [invocable](concept.invocable#concept:invocable "18.7.2 Concept invocable [concept.invocable]") && [uniform_random_bit_generator](rand.req.urng#concept:uniform_random_bit_generator "29.5.3.3 Uniform random bit generator requirements [rand.req.urng]")> && is_arithmetic_v>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_distributiontemplateclass 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_distributiontemplateclass 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_distributiontemplateclass binomial_distribution; // [[rand.dist.bern.geo]](rand.dist.bern.geo "29.5.9.3.3 Class template geometric_­distribution"), class template geometric_distributiontemplateclass geometric_distribution; // [[rand.dist.bern.negbin]](rand.dist.bern.negbin "29.5.9.3.4 Class template negative_­binomial_­distribution"), class template negative_binomial_distributiontemplateclass negative_binomial_distribution; // [[rand.dist.pois.poisson]](rand.dist.pois.poisson "29.5.9.4.1 Class template poisson_­distribution"), class template poisson_distributiontemplateclass poisson_distribution; // [[rand.dist.pois.exp]](rand.dist.pois.exp "29.5.9.4.2 Class template exponential_­distribution"), class template exponential_distributiontemplateclass exponential_distribution; // [[rand.dist.pois.gamma]](rand.dist.pois.gamma "29.5.9.4.3 Class template gamma_­distribution"), class template gamma_distributiontemplateclass gamma_distribution; // [[rand.dist.pois.weibull]](rand.dist.pois.weibull "29.5.9.4.4 Class template weibull_­distribution"), class template weibull_distributiontemplateclass weibull_distribution; // [[rand.dist.pois.extreme]](rand.dist.pois.extreme "29.5.9.4.5 Class template extreme_­value_­distribution"), class template extreme_value_distributiontemplateclass extreme_value_distribution; // [[rand.dist.norm.normal]](rand.dist.norm.normal "29.5.9.5.1 Class template normal_­distribution"), class template normal_distributiontemplateclass normal_distribution; // [[rand.dist.norm.lognormal]](rand.dist.norm.lognormal "29.5.9.5.2 Class template lognormal_­distribution"), class template lognormal_distributiontemplateclass lognormal_distribution; // [[rand.dist.norm.chisq]](rand.dist.norm.chisq "29.5.9.5.3 Class template chi_­squared_­distribution"), class template chi_squared_distributiontemplateclass chi_squared_distribution; // [[rand.dist.norm.cauchy]](rand.dist.norm.cauchy "29.5.9.5.4 Class template cauchy_­distribution"), class template cauchy_distributiontemplateclass cauchy_distribution; // [[rand.dist.norm.f]](rand.dist.norm.f "29.5.9.5.5 Class template fisher_­f_­distribution"), class template fisher_f_distributiontemplateclass 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_distributiontemplateclass student_t_distribution; // [[rand.dist.samp.discrete]](rand.dist.samp.discrete "29.5.9.6.1 Class template discrete_­distribution"), class template discrete_distributiontemplateclass discrete_distribution; // [[rand.dist.samp.pconst]](rand.dist.samp.pconst "29.5.9.6.2 Class template piecewise_­constant_­distribution"), class template piecewise_constant_distributiontemplateclass 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_distributiontemplateclass piecewise_linear_distribution;}