Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Standard library header <random> (C++11)

      From cppreference.com
      <cpp‎ |header
       
       
      Standard library headers
       

      This header is part of thepseudo-random number generation library.

      Contents

      Includes

      std::initializer_list class template[edit]

      Concepts

      Uniform random bit generator requirements
      specifies that a type qualifies as a uniform random bit generator
      (concept)[edit]

      Classes

      Random number engines
      implementslinear congruential algorithm
      (class template)[edit]
      implementsMersenne twister algorithm
      (class template)[edit]
      implements a subtract-with-carry (lagged Fibonacci) algorithm
      (class template)[edit]
      a counter-based parallelizable generator
      (class template)[edit]
      Random number engine adaptors
      discards some output of a random number engine
      (class template)[edit]
      packs the output of a random number engine into blocks of a specified number of bits
      (class template)[edit]
      delivers the output of a random number engine in a different order
      (class template)[edit]
      Predefined generators
      minstd_rand0(C++11)std::linear_congruential_engine<std::uint_fast32_t,
                                      16807,0,2147483647>

      Discovered in 1969 by Lewis, Goodman and Miller, adopted as "Minimal standard" in 1988 by Park and Miller[edit]

      minstd_rand(C++11)

      std::linear_congruential_engine<std::uint_fast32_t,
                                      48271,0,2147483647>
      Newer "Minimum standard", recommended by Park, Miller, and Stockmeyer in 1993[edit]

      mt19937(C++11)

      std::mersenne_twister_engine<std::uint_fast32_t,
                                   32,624,397,31,
                                   0x9908b0df,11,
                                   0xffffffff,7,
                                   0x9d2c5680,15,
                                   0xefc60000,18,1812433253>
      32-bit Mersenne Twister by Matsumoto and Nishimura, 1998[edit]

      mt19937_64(C++11)

      std::mersenne_twister_engine<std::uint_fast64_t,
                                   64,312,156,31,
                                   0xb5026f5aa96619e9,29,
                                   0x5555555555555555,17,
                                   0x71d67fffeda60000,37,
                                   0xfff7eee000000000,43,
                                   6364136223846793005>
      64-bit Mersenne Twister by Matsumoto and Nishimura, 2000[edit]

      ranlux24_base(C++11)std::subtract_with_carry_engine<std::uint_fast32_t,24,10,24>[edit]
      ranlux48_base(C++11)std::subtract_with_carry_engine<std::uint_fast64_t,48,5,12>[edit]
      ranlux24(C++11)std::discard_block_engine<std::ranlux24_base,223,23>

      24-bit RANLUX generator by Martin Lüscher and Fred James, 1994[edit]

      ranlux48(C++11)std::discard_block_engine<std::ranlux48_base,389,11>

      48-bit RANLUX generator by Martin Lüscher and Fred James, 1994[edit]

      knuth_b(C++11)std::shuffle_order_engine<std::minstd_rand0,256>[edit]
      philox4x32(C++26)std::philox_engine<std::uint_fast32_t,32,4,10,
                         0xCD9E8D57,0x9E3779B9,
                         0xD2511F53,0xBB67AE85>[edit]
      philox4x64(C++26)std::philox_engine<std::uint_fast64_t,64,4,10,
                         0xCA5A826395121157,0x9E3779B97F4A7C15,
                         0xD2E7470EE14C6C93,0xBB67AE8584CAA73B>[edit]
      default_random_engine(C++11) an implementation-definedRandomNumberEngine type
      Non-deterministic random numbers
      non-deterministic random number generator using hardware entropy source
      (class)[edit]
      Uniform distributions
      produces integer values evenly distributed across a range
      (class template)[edit]
      produces real values evenly distributed across a range
      (class template)[edit]
      Bernoulli distributions
      producesbool values on aBernoulli distribution
      (class)[edit]
      produces integer values on abinomial distribution
      (class template)[edit]
      produces integer values on anegative binomial distribution
      (class template)[edit]
      produces integer values on ageometric distribution
      (class template)[edit]
      Poisson distributions
      produces integer values on aPoisson distribution
      (class template)[edit]
      produces real values on anexponential distribution
      (class template)[edit]
      produces real values on agamma distribution
      (class template)[edit]
      produces real values on aWeibull distribution
      (class template)[edit]
      produces real values on anextreme value distribution
      (class template)[edit]
      Normal distributions
      produces real values on astandard normal (Gaussian) distribution
      (class template)[edit]
      produces real values on alognormal distribution
      (class template)[edit]
      produces real values on achi-squared distribution
      (class template)[edit]
      produces real values on aCauchy distribution
      (class template)[edit]
      produces real values on aFisher's F-distribution
      (class template)[edit]
      produces real values on aStudent's t-distribution
      (class template)[edit]
      Sampling distributions
      produces integer values on a discrete distribution
      (class template)[edit]
      produces real values distributed on constant subintervals
      (class template)[edit]
      produces real values distributed on defined subintervals
      (class template)[edit]
      Utilities
      (C++11)
      general-purpose bias-eliminating scrambled seed sequence generator
      (class)[edit]

      Functions

      evenly distributes real values of given precision across[01)
      (function template)[edit]
      fills a range with random numbers from a uniform random bit generator
      (algorithm function object)[edit]

      [edit]Synopsis

      #include <initializer_list> namespace std{// uniform random bit generator requirementstemplate<class G>  concept uniform_random_bit_generator=/* see description */;// freestanding // class template linear_congruential_enginetemplate<class UIntType, UIntType a, UIntType c, UIntType m>class linear_congruential_engine;// partially freestanding // 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;// partially freestanding // class template subtract_with_carry_enginetemplate<class UIntType, size_t w, size_t s, size_t r>class subtract_with_carry_engine;// partially freestanding // class template discard_block_enginetemplate<class Engine, size_t p, size_t r>class discard_block_engine;// partially freestanding // class template independent_bits_enginetemplate<class Engine, size_t w,class UIntType>class independent_bits_engine;// partially freestanding // class template shuffle_order_enginetemplate<class Engine, size_t k>class shuffle_order_engine; // class template philox_enginetemplate<class UIntType, size_t w, size_t n, size_t r, UIntType...consts>class philox_engine;// partially freestanding // engines and engine adaptors with predefined parametersusing minstd_rand0=/* see description */;// freestandingusing minstd_rand=/* see description */;// freestandingusing mt19937=/* see description */;// freestandingusing mt19937_64=/* see description */;// freestandingusing ranlux24_base=/* see description */;// freestandingusing ranlux48_base=/* see description */;// freestandingusing ranlux24=/* see description */;// freestandingusing ranlux48=/* see description */;// freestandingusing knuth_b=/* see description */;using philox4x32=/* see description */;// freestandingusing philox4x64=/* see description */;// freestanding using default_random_engine=/* see description */; // class random_deviceclass random_device; // class seed_seqclass seed_seq; // function template generate_canonicaltemplate<class RealType, size_t digits,class URBG>  RealType generate_canonical(URBG& g); namespace ranges{// generate_randomtemplate<class R,class G>      requires output_range<R, invoke_result_t<G&>>&&               uniform_random_bit_generator<remove_cvref_t<G>>constexpr borrowed_iterator_t<R> generate_random(R&& r, G&& g); template<class G, output_iterator<invoke_result_t<G&>> O, sentinel_for<O> S>      requires uniform_random_bit_generator<remove_cvref_t<G>>constexpr O generate_random(O first, S last, G&& g); template<class R,class G,class D>      requires output_range<R, invoke_result_t<D&, G&>>&& invocable<D&, G&>&&               uniform_random_bit_generator<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<invoke_result_t<D&, G&>> O, sentinel_for<O> S>      requires invocable<D&, G&>&& uniform_random_bit_generator<remove_cvref_t<G>>&&               is_arithmetic_v<invoke_result_t<D&, G&>>constexpr O generate_random(O first, S last, G&& g, D&& d);} // class template uniform_int_distributiontemplate<class IntType=int>class uniform_int_distribution;// partially freestanding // class template uniform_real_distributiontemplate<class RealType=double>class uniform_real_distribution; // class bernoulli_distributionclass bernoulli_distribution; // class template binomial_distributiontemplate<class IntType=int>class binomial_distribution; // class template geometric_distributiontemplate<class IntType=int>class geometric_distribution; // class template negative_binomial_distributiontemplate<class IntType=int>class negative_binomial_distribution; // class template poisson_distributiontemplate<class IntType=int>class poisson_distribution; // class template exponential_distributiontemplate<class RealType=double>class exponential_distribution; // class template gamma_distributiontemplate<class RealType=double>class gamma_distribution; // class template weibull_distributiontemplate<class RealType=double>class weibull_distribution; // class template extreme_value_distributiontemplate<class RealType=double>class extreme_value_distribution; // class template normal_distributiontemplate<class RealType=double>class normal_distribution; // class template lognormal_distributiontemplate<class RealType=double>class lognormal_distribution; // class template chi_squared_distributiontemplate<class RealType=double>class chi_squared_distribution; // class template cauchy_distributiontemplate<class RealType=double>class cauchy_distribution; // class template fisher_f_distributiontemplate<class RealType=double>class fisher_f_distribution; // class template student_t_distributiontemplate<class RealType=double>class student_t_distribution; // class template discrete_distributiontemplate<class IntType=int>class discrete_distribution; // class template piecewise_constant_distributiontemplate<class RealType=double>class piecewise_constant_distribution; // class template piecewise_linear_distributiontemplate<class RealType=double>class piecewise_linear_distribution;}

      [edit]Conceptuniform_random_bit_generator

      namespace std{template<class G>  concept uniform_random_bit_generator=    invocable<G&>&& unsigned_integral<invoke_result_t<G&>>&& requires{{        G::min()}-> same_as<invoke_result_t<G&>>;{        G::max()}-> same_as<invoke_result_t<G&>>;      requires bool_constant<(G::min()< G::max())>::value;};}

      [edit]Class templatestd::linear_congruential_engine

      namespace std{template<class UIntType, UIntType a, UIntType c, UIntType m>class linear_congruential_engine{public:// typesusing result_type= UIntType; // engine characteristicsstaticconstexpr result_type multiplier= a;staticconstexpr result_type increment= c;staticconstexpr result_type modulus= m;staticconstexpr result_type min(){return c== 0u? 1u: 0u;}staticconstexpr result_type max(){return m- 1u;}staticconstexpr result_type default_seed= 1u; // constructors and seeding functions    linear_congruential_engine(): linear_congruential_engine(default_seed){}explicit linear_congruential_engine(result_type s);template<class Sseq>explicit linear_congruential_engine(Sseq& q);void seed(result_type s= default_seed);template<class Sseq>void seed(Sseq& q); // equality operatorsfriendbool operator==(const linear_congruential_engine& x,const linear_congruential_engine& y); // generating functions    result_type operator()();void discard(unsignedlonglong z); // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>&      operator<<(basic_ostream<CharT, Traits>& os,// hostedconst linear_congruential_engine& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>&      operator>>(basic_istream<CharT, Traits>& is,// hosted                 linear_congruential_engine& x);};}

      [edit]Class templatestd::mersenne_twister_engine

      namespace std{template<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{public:// typesusing result_type= UIntType; // engine characteristicsstaticconstexpr size_t word_size= w;staticconstexpr size_t state_size= n;staticconstexpr size_t shift_size= m;staticconstexpr size_t mask_bits= r;staticconstexpr UIntType xor_mask= a;staticconstexpr size_t tempering_u= u;staticconstexpr UIntType tempering_d= d;staticconstexpr size_t tempering_s= s;staticconstexpr UIntType tempering_b= b;staticconstexpr size_t tempering_t= t;staticconstexpr UIntType tempering_c= c;staticconstexpr size_t tempering_l= l;staticconstexpr UIntType initialization_multiplier= f;staticconstexpr result_type min(){return0;}staticconstexpr result_type max(){return/*2^w - 1*/;}staticconstexpr result_type default_seed= 5489u; // constructors and seeding functions    mersenne_twister_engine(): mersenne_twister_engine(default_seed){}explicit mersenne_twister_engine(result_type value);template<class Sseq>explicit mersenne_twister_engine(Sseq& q);void seed(result_type value= default_seed);template<class Sseq>void seed(Sseq& q); // equality operatorsfriendbool operator==(const mersenne_twister_engine& x,const mersenne_twister_engine& y); // generating functions    result_type operator()();void discard(unsignedlonglong z); // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>&      operator<<(basic_ostream<CharT, Traits>& os,// hostedconst mersenne_twister_engine& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>&      operator>>(basic_istream<CharT, Traits>& is,// hosted                 mersenne_twister_engine& x);};}

      [edit]Class templatestd::subtract_with_carry_engine

      namespace std{template<class UIntType, size_t w, size_t s, size_t r>class subtract_with_carry_engine{public:// typesusing result_type= UIntType; // engine characteristicsstaticconstexpr size_t word_size= w;staticconstexpr size_t short_lag= s;staticconstexpr size_t long_lag= r;staticconstexpr result_type min(){return0;}staticconstexpr result_type max(){return/*m - 1*/;}staticconstexpr uint_least32_t default_seed= 19780503u; // constructors and seeding functions    subtract_with_carry_engine(): subtract_with_carry_engine(0u){}explicit subtract_with_carry_engine(result_type value);template<class Sseq>explicit subtract_with_carry_engine(Sseq& q);void seed(result_type value= 0u);template<class Sseq>void seed(Sseq& q); // equality operatorsfriendbool operator==(const subtract_with_carry_engine& x,const subtract_with_carry_engine& y); // generating functions    result_type operator()();void discard(unsignedlonglong z); // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>&      operator<<(basic_ostream<CharT, Traits>& os,// hostedconst subtract_with_carry_engine& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>&      operator>>(basic_istream<CharT, Traits>& is,// hosted                 subtract_with_carry_engine& x);};}

      [edit]Class templatestd::philox_engine

      namespace std{template<class UIntType, size_t w, size_t n, size_t r, UIntType...consts>class philox_engine{staticconstexpr size_t/*array-size*/= n/2;// exposition onlypublic:// typesusing result_type= UIntType; // engine characteristicsstaticconstexpr size_t word_size= w;staticconstexpr size_t word_count= n;staticconstexpr size_t round_count= r;staticconstexpr array<result_type,/*array-size*/> multipliers;staticconstexpr array< result_type, @exposition onlyid{ array- size>}    @round_consts;staticconstexpr result_type min(){return0;}staticconstexpr result_type max(){return m-1;}staticconstexpr result_type default_seed= 20111115u; // constructors and seeding functions    philox_engine(): philox_engine(default_seed){}explicit philox_engine(result_type value);template<class Sseq>explicit philox_engine(Sseq& q);void seed(result_type value= default_seed);template<class Sseq>void seed(Sseq& q); void set_counter(const array<result_type, n>& counter); // equality operatorsfriendbool operator==(const philox_engine& x,const philox_engine& y); // generating functions    result_type operator()();void discard(unsignedlonglong z); // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>&      operator<<(basic_ostream<CharT, Traits>& os,// hostedconst philox_engine& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>&      operator>>(basic_istream<CharT, Traits>& is,// hosted                 philox_engine& x);};}

      [edit]Class templatestd::discard_block_engine

      namespace std{template<class Engine, size_t p, size_t r>class discard_block_engine{public:// typesusing result_type=typename Engine::result_type; // engine characteristicsstaticconstexpr size_t block_size= p;staticconstexpr size_t used_block= r;staticconstexpr result_type min(){return Engine::min();}staticconstexpr result_type max(){return Engine::max();} // constructors and seeding functions    discard_block_engine();explicit discard_block_engine(const Engine& e);explicit discard_block_engine(Engine&& e);explicit discard_block_engine(result_type s);template<class Sseq>explicit discard_block_engine(Sseq& q);void seed();void seed(result_type s);template<class Sseq>void seed(Sseq& q); // equality operatorsfriendbool operator==(const discard_block_engine& x,const discard_block_engine& y); // generating functions    result_type operator()();void discard(unsignedlonglong z); // property functionsconst Engine& base()constnoexcept{return e;} // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>&      operator<<(basic_ostream<CharT, Traits>& os,// hostedconst discard_block_engine& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>&      operator>>(basic_istream<CharT, Traits>& is,// hosted                 discard_block_engine& x); private:    Engine e;// exposition only    size_t n;// exposition only};}

      [edit]Class templatestd::independent_bits_engine

      namespace std{template<class Engine, size_t w,class UIntType>class independent_bits_engine{public:// typesusing result_type= UIntType; // engine characteristicsstaticconstexpr result_type min(){return0;}staticconstexpr result_type max(){return/*2^w - 1*/;} // constructors and seeding functions    independent_bits_engine();explicit independent_bits_engine(const Engine& e);explicit independent_bits_engine(Engine&& e);explicit independent_bits_engine(result_type s);template<class Sseq>explicit independent_bits_engine(Sseq& q);void seed();void seed(result_type s);template<class Sseq>void seed(Sseq& q); // equality operatorsfriendbool operator==(const independent_bits_engine& x,const independent_bits_engine& y); // generating functions    result_type operator()();void discard(unsignedlonglong z); // property functionsconst Engine& base()constnoexcept{return e;} // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>&      operator<<(basic_ostream<CharT, Traits>& os,// hostedconst independent_bits_engine& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>&      operator>>(basic_istream<CharT, Traits>& is,// hosted                 independent_bits_engine& x); private:    Engine e;// exposition only};}

      [edit]Class templatestd::shuffle_order_engine

      namespace std{template<class Engine, size_t k>class shuffle_order_engine{public:// typesusing result_type=typename Engine::result_type; // engine characteristicsstaticconstexpr size_t table_size= k;staticconstexpr result_type min(){return Engine::min();}staticconstexpr result_type max(){return Engine::max();} // constructors and seeding functions    shuffle_order_engine();explicit shuffle_order_engine(const Engine& e);explicit shuffle_order_engine(Engine&& e);explicit shuffle_order_engine(result_type s);template<class Sseq>explicit shuffle_order_engine(Sseq& q);void seed();void seed(result_type s);template<class Sseq>void seed(Sseq& q); // equality operatorsfriendbool operator==(const shuffle_order_engine& x,const shuffle_order_engine& y); // generating functions    result_type operator()();void discard(unsignedlonglong z); // property functionsconst Engine& base()constnoexcept{return e;} // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const shuffle_order_engine& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    shuffle_order_engine& x); private:    Engine e;// exposition only    result_type V[k];// exposition only    result_type Y;// exposition only};}

      [edit]Engines and engine adaptors with predefined parameters

      namespace std{using minstd_rand0= linear_congruential_engine<uint_fast32_t,16'807, 0, 2'147'483'647>;using minstd_rand= linear_congruential_engine<uint_fast32_t,48'271, 0, 2'147'483'647>;using mt19937= mersenne_twister_engine<uint_fast32_t,32,624,397,31,0x9908'b0df,                                        11,                                        0xffff'ffff,7,0x9d2c'5680,                                        15,                                        0xefc6'0000,18,1'812'433'253>; //'using mt19937_64= mersenne_twister_engine<uint_fast64_t,64,312,156,31,0xb502'6f5a'a966'19e9,                                           29,                                           0x5555'5555'5555'5555,17,0x71d6'7fff'eda6'0000,                                           37,                                           0xfff7'eee0'0000'0000,43,6'364'136'223'846'793'005>;using ranlux24_base= subtract_with_carry_engine<uint_fast32_t,24,10,24>;using ranlux48_base= subtract_with_carry_engine<uint_fast64_t,48,5,12>;using ranlux24= discard_block_engine<ranlux24_base,223,23>;using ranlux48= discard_block_engine<ranlux48_base,389,11>;using knuth_b= shuffle_order_engine<minstd_rand0,256>;using default_random_engine=/* implementation-defined */;using philox4x32= philox_engine<uint_fast32_t,32,4,10,0xD2511F53,0x9E3779B9,0xCD9E8D57,0xBB67AE85>;using philox4x64= philox_engine<uint_fast64_t,64,4,10,0xD2E7470EE14C6C93,0x9E3779B97F4A7C15,0xCA5A826395121157,0xBB67AE8584CAA73B>;}

      [edit]Classstd::random_device

      namespace std{class random_device{public:// typesusing result_type=unsignedint; // generator characteristicsstaticconstexpr result_type min(){return numeric_limits<result_type>::min();}staticconstexpr result_type max(){return numeric_limits<result_type>::max();} // constructors    random_device(): random_device(/* implementation-defined */){}explicit random_device(const string& token); // generating functions    result_type operator()(); // property functionsdouble entropy()constnoexcept; // no copy functions    random_device(const random_device&)= delete;void operator=(const random_device&)= delete;};}

      [edit]Classstd::seed_seq

      namespace std{class seed_seq{public:// typesusing result_type= uint_least32_t; // constructors    seed_seq()noexcept;template<class T>    seed_seq(initializer_list<T> il);template<class InputIter>    seed_seq(InputIter begin, InputIter end); // generating functionstemplate<class RandomAccessIter>void generate(RandomAccessIter begin, RandomAccessIter end); // property functions    size_t size()constnoexcept;template<class OutputIter>void param(OutputIter dest)const; // no copy functions    seed_seq(const seed_seq&)= delete;void operator=(const seed_seq&)= delete; private:    vector<result_type> v;// exposition only};}

      [edit]Class templatestd::uniform_int_distribution

      namespace std{template<class IntType=int>class uniform_int_distribution{public:// typesusing result_type= IntType;using param_type=/* unspecified */; // constructors and reset functions    uniform_int_distribution(): uniform_int_distribution(0){}explicit uniform_int_distribution(IntType a,                                      IntType b= numeric_limits<IntType>::max());explicit uniform_int_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const uniform_int_distribution& x,const uniform_int_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    result_type a()const;    result_type b()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>&      operator<<(basic_ostream<CharT, Traits>& os,// hostedconst uniform_int_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>&      operator>>(basic_istream<CharT, Traits>& is,// hosted                 uniform_int_distribution& x);};}

      [edit]Class templatestd::uniform_real_distribution

      namespace std{template<class RealType=double>class uniform_real_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructors and reset functions    uniform_real_distribution(): uniform_real_distribution(0.0){}explicit uniform_real_distribution(RealType a, RealType b=1.0);explicit uniform_real_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const uniform_real_distribution& x,const uniform_real_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    result_type a()const;    result_type b()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const uniform_real_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    uniform_real_distribution& x);};}

      [edit]Classstd::bernoulli_distribution

      namespace std{class bernoulli_distribution{public:// typesusing result_type=bool;using param_type=/* unspecified */; // constructors and reset functions    bernoulli_distribution(): bernoulli_distribution(0.5){}explicit bernoulli_distribution(double p);explicit bernoulli_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const bernoulli_distribution& x,const bernoulli_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functionsdouble p()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const bernoulli_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    bernoulli_distribution& x);};}

      [edit]Class templatestd::binomial_distribution

      namespace std{template<class IntType=int>class binomial_distribution{public:// typesusing result_type= IntType;using param_type=/* unspecified */; // constructors and reset functions    binomial_distribution(): binomial_distribution(1){}explicit binomial_distribution(IntType t,double p=0.5);explicit binomial_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const binomial_distribution& x,const binomial_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    IntType t()const;double p()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const binomial_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    binomial_distribution& x);};}

      [edit]Class templatestd::geometric_distribution

      namespace std{template<class IntType=int>class geometric_distribution{public:// typesusing result_type= IntType;using param_type=/* unspecified */; // constructors and reset functions    geometric_distribution(): geometric_distribution(0.5){}explicit geometric_distribution(double p);explicit geometric_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const geometric_distribution& x,const geometric_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functionsdouble p()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const geometric_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    geometric_distribution& x);};}

      [edit]Class templatestd::negative_binomial_distribution

      namespace std{template<class IntType=int>class negative_binomial_distribution{public:// typesusing result_type= IntType;using param_type=/* unspecified */; // constructor and reset functions    negative_binomial_distribution(): negative_binomial_distribution(1){}explicit negative_binomial_distribution(IntType k,double p=0.5);explicit negative_binomial_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const negative_binomial_distribution& x,const negative_binomial_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    IntType k()const;double p()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(      basic_ostream<CharT, Traits>& os,const negative_binomial_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    negative_binomial_distribution& x);};}

      [edit]Class templatestd::poisson_distribution

      namespace std{template<class IntType=int>class poisson_distribution{public:// typesusing result_type= IntType;using param_type=/* unspecified */; // constructors and reset functions    poisson_distribution(): poisson_distribution(1.0){}explicit poisson_distribution(double mean);explicit poisson_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const poisson_distribution& x,const poisson_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functionsdouble mean()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const poisson_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    poisson_distribution& x);};}

      [edit]Class templatestd::exponential_distribution

      namespace std{template<class RealType=double>class exponential_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructors and reset functions    exponential_distribution(): exponential_distribution(1.0){}explicit exponential_distribution(RealType lambda);explicit exponential_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const exponential_distribution& x,const exponential_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType lambda()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const exponential_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    exponential_distribution& x);};}

      [edit]Class templatestd::gamma_distribution

      namespace std{template<class RealType=double>class gamma_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructors and reset functions    gamma_distribution(): gamma_distribution(1.0){}explicit gamma_distribution(RealType alpha, RealType beta=1.0);explicit gamma_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const gamma_distribution& x,const gamma_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType alpha()const;    RealType beta()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const gamma_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    gamma_distribution& x);};}

      [edit]Class templatestd::weibull_distribution

      namespace std{template<class RealType=double>class weibull_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    weibull_distribution(): weibull_distribution(1.0){}explicit weibull_distribution(RealType a, RealType b=1.0);explicit weibull_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const weibull_distribution& x,const weibull_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType a()const;    RealType b()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const weibull_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    weibull_distribution& x);};}

      [edit]Class templatestd::extreme_value_distribution

      namespace std{template<class RealType=double>class extreme_value_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    extreme_value_distribution(): extreme_value_distribution(0.0){}explicit extreme_value_distribution(RealType a, RealType b=1.0);explicit extreme_value_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const extreme_value_distribution& x,const extreme_value_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType a()const;    RealType b()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const extreme_value_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    extreme_value_distribution& x);};}

      [edit]Class templatestd::normal_distribution

      namespace std{template<class RealType=double>class normal_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructors and reset functions    normal_distribution(): normal_distribution(0.0){}explicit normal_distribution(RealType mean, RealType stddev=1.0);explicit normal_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const normal_distribution& x,const normal_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType mean()const;    RealType stddev()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const normal_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    normal_distribution& x);};}

      [edit]Class templatestd::lognormal_distribution

      namespace std{template<class RealType=double>class lognormal_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    lognormal_distribution(): lognormal_distribution(0.0){}explicit lognormal_distribution(RealType m, RealType s=1.0);explicit lognormal_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const lognormal_distribution& x,const lognormal_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType m()const;    RealType s()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const lognormal_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    lognormal_distribution& x);};}

      [edit]Class templatestd::chi_squared_distribution

      namespace std{template<class RealType=double>class chi_squared_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    chi_squared_distribution(): chi_squared_distribution(1.0){}explicit chi_squared_distribution(RealType n);explicit chi_squared_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const chi_squared_distribution& x,const chi_squared_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType n()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const chi_squared_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    chi_squared_distribution& x);};}

      [edit]Class templatestd::cauchy_distribution

      namespace std{template<class RealType=double>class cauchy_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    cauchy_distribution(): cauchy_distribution(0.0){}explicit cauchy_distribution(RealType a, RealType b=1.0);explicit cauchy_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const cauchy_distribution& x,const cauchy_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType a()const;    RealType b()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const cauchy_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    cauchy_distribution& x);};}

      [edit]Class templatestd::fisher_f_distribution

      namespace std{template<class RealType=double>class fisher_f_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    fisher_f_distribution(): fisher_f_distribution(1.0){}explicit fisher_f_distribution(RealType m, RealType n=1.0);explicit fisher_f_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const fisher_f_distribution& x,const fisher_f_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType m()const;    RealType n()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const fisher_f_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    fisher_f_distribution& x);};}

      [edit]Class templatestd::student_t_distribution

      namespace std{template<class RealType=double>class student_t_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    student_t_distribution(): student_t_distribution(1.0){}explicit student_t_distribution(RealType n);explicit student_t_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const student_t_distribution& x,const student_t_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    RealType n()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const student_t_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    student_t_distribution& x);};}

      [edit]Class templatestd::discrete_distribution

      namespace std{template<class IntType=int>class discrete_distribution{public:// typesusing result_type= IntType;using param_type=/* unspecified */; // constructor and reset functions    discrete_distribution();template<class InputIter>    discrete_distribution(InputIter firstW, InputIter lastW);    discrete_distribution(initializer_list<double> wl);template<class UnaryOperation>    discrete_distribution(size_t nw,double xmin,double xmax, UnaryOperation fw);explicit discrete_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const discrete_distribution& x,const discrete_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    vector<double> probabilities()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& os,const discrete_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    discrete_distribution& x);};}

      [edit]Class templatestd::piecewise_constant_distribution

      namespace std{template<class RealType=double>class piecewise_constant_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    piecewise_constant_distribution();template<class InputIterB,class InputIterW>    piecewise_constant_distribution(InputIterB firstB,                                    InputIterB lastB,                                    InputIterW firstW);template<class UnaryOperation>    piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);template<class UnaryOperation>    piecewise_constant_distribution(size_t nw,                                    RealType xmin,                                    RealType xmax,                                    UnaryOperation fw);explicit piecewise_constant_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const piecewise_constant_distribution& x,const piecewise_constant_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    vector<result_type> intervals()const;    vector<result_type> densities()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(      basic_ostream<CharT, Traits>& os,const piecewise_constant_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    piecewise_constant_distribution& x);};}

      [edit]Class templatestd::piecewise_linear_distribution

      namespace std{template<class RealType=double>class piecewise_linear_distribution{public:// typesusing result_type= RealType;using param_type=/* unspecified */; // constructor and reset functions    piecewise_linear_distribution();template<class InputIterB,class InputIterW>    piecewise_linear_distribution(InputIterB firstB, InputIterB lastB, InputIterW firstW);template<class UnaryOperation>    piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);template<class UnaryOperation>    piecewise_linear_distribution(size_t nw,                                  RealType xmin,                                  RealType xmax,                                  UnaryOperation fw);explicit piecewise_linear_distribution(const param_type& parm);void reset(); // equality operatorsfriendbool operator==(const piecewise_linear_distribution& x,const piecewise_linear_distribution& y); // generating functionstemplate<class URBG>    result_type operator()(URBG& g);template<class URBG>    result_type operator()(URBG& g,const param_type& parm); // property functions    vector<result_type> intervals()const;    vector<result_type> densities()const;    param_type param()const;void param(const param_type& parm);    result_type min()const;    result_type max()const; // inserters and extractorstemplate<class CharT,class Traits>friend basic_ostream<CharT, Traits>& operator<<(      basic_ostream<CharT, Traits>& os,const piecewise_linear_distribution& x);template<class CharT,class Traits>friend basic_istream<CharT, Traits>& operator>>(basic_istream<CharT, Traits>& is,                                                    piecewise_linear_distribution& x);};}
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/header/random&oldid=180375"

      [8]ページ先頭

      ©2009-2025 Movatter.jp