构造分发点对应。
normal_distribution(result_type mean0 = result_type(0.0),
result_type sigma0 = result_type(1.0));
explicit normal_distribution(const param_type& par0);
参数
mean0
平均分布参数。sigma0
斯格的分发参数。par0
使用的参数包构造分布。
备注
前置条件: 0.0 <= sigma0
第一个构造函数构造存储值 stored_mean 保存值 mean0,并存储值 stored_sigma 表示值 sigma0的对象。
第二个构造函数构造存储参数从 par0初始化的对象。
示例
// std_tr1__random__normal_distribution_construct.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::ranlux64_base_01 Myeng;
typedef std::normal_distribution<double> Mydist;
int main()
{
Myeng eng;
Mydist dist(1.5, 2.0);
Mydist::input_type engval = eng();
Mydist::result_type distval = dist(eng);
distval = distval; // to quiet "unused" warnings
engval = engval;
std::cout << "mean == " << dist.mean() << std::endl;
std::cout << "sigma == " << dist.sigma() << std::endl;
dist.reset(); // discard any cached values
std::cout << "a random value == " << dist(eng) << std::endl;
std::cout << "a random value == " << dist(eng) << std::endl;
std::cout << "a random value == " << dist(eng) << std::endl;
return (0);
}
要求
标头: <random>
命名空间: std