#include #include #include #include #include #include using namespace std;int main(){ const auto random_seed = 199712; std::default_random_engine engine(static_cast(random_seed)); //定义随机数生成引擎 std::uniform_real_distribution even(-3.0, 3.0);//取值范围 std::vectorvalueVector(20); for(std::size_t i=0; i < 20; ++i) { valueVector[i] = even(engine);//按照上述平均分布生成随机数 } for (std::size_t j=0; j < valueVector.size(); ++j) std::cout << valueVector[j]<
#include #include #include #include #include #include using namespace std;int main(){ auto seed = 19917; std::default_random_engine e(static_cast(seed)); //定义随机数生成引擎 std::normal_distribution n(4.0, 0.517);//4.0 是均值, 0.517是方差 std::vectorvalueVector(20); for(std::size_t i=0; i < 20; ++i) { valueVector[i] = n(e);//按照上述正态分布生成随机数 } for (std::size_t j=0; j < valueVector.size(); ++j) std::cout << valueVector[j]<