RosettaCodeData/Task/Random-numbers/C++/random-numbers-3.cpp

21 lines
607 B
C++
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
#include <vector>
2013-06-05 21:47:54 +00:00
#include "boost/random.hpp"
#include "boost/generator_iterator.hpp"
#include <boost/random/normal_distribution.hpp>
2013-04-10 23:57:08 -07:00
#include <algorithm>
2013-06-05 21:47:54 +00:00
typedef boost::mt19937 RNGType; ///< mersenne twister generator
2013-04-10 23:57:08 -07:00
2013-06-05 21:47:54 +00:00
int main() {
RNGType rng;
boost::normal_distribution<> rdist(1.0,0.5); /**< normal distribution
with mean of 1.0 and standard deviation of 0.5 */
boost::variate_generator< RNGType, boost::normal_distribution<> >
get_rand(rng, rdist);
std::vector<double> v(1000);
generate(v.begin(),v.end(),get_rand);
return 0;
2013-04-10 23:57:08 -07:00
}