标签:
std::default_random_engine generator; std::uniform_int_distribution<int> dis(0,100); for(int i=0;i<5;i++) { std::cout<<dis(generator)<<std::endl; }
std::default_random_engine generator; std::uniform_int_distribution<int> dis(0,100); auto dice= std::bind(dis,generator); for(int i=0;i<5;i++) { std::cout<<dice()<<std::endl; }
linear_congruential_engine 线性同余法mersenne_twister_engine 梅森旋转法substract_with_carry_engine 滞后Fibonacci
template <class UIntType, UIntType a, UIntType c, UIntType m>class linear_congruential_engine;第一个参数:生成器类型unsigned int,unsigned long等第二到第四个参数:是线性同余法公递推公式Nj+i =(AxNj+C) (mod M)里的三个常数值A,C,M要求:如果m不为0,a,c的值要小于m
typedef linear_congruential<unsigned long, 48271, 0, 2147483647> minstd_rand; typedef linear_congruential<unsigned long, 16807, 0, 2147483647> minstd_rand0;
minstd_rand()minstd_rand0利用适配器变种后的线性同余法knuth_b minstd_rand0 with shuffle_order_engine
default_random_engine()mt19937mt19937_64
ranlux24_baseranlux48_base
ranlux24 ranlux24_base with discard_block_engineranlux48 ranlux48_base with discard_block_engine
作用1:改变生成类型,利用模版参数作用2:改变值区间,利用实例构造函数参数。或其响应的成员函数设置参数。作用3:改变概率分布,选用不同的分布器类型
uniform_int_distribution 整数均匀分布uniform_real_distribution 浮点数均匀分布
bernoulli_distribution 伯努利分布binomial_distribution 二项分布geometry_distribution 几何分布negative_biomial_distribution 负二项分布
poisson_distribution 泊松分布exponential_distribution 指数分布gamma_distribution 伽马分布weibull_distribution 威布尔分布extreme_value_distribution 极值分布
normal_distribution 正态分布chi_squared_distribution 卡方分布cauchy_distribution 柯西分布fisher_f_distribution 费歇尔F分布student_t_distribution t分布
discrete_distribution 离散分布piecewise_constant_distribution 分段常数分布piecewise_linear_distribution 分段线性分布
标签:
原文地址:http://www.cnblogs.com/DswCnblog/p/5624869.html