20 #include <boost/shared_ptr.hpp> 59 std::random_device rd;
60 std::mt19937 gen(rd());
64 std::normal_distribution<>
d(mean, var);
79 std::random_device rd;
80 std::mt19937 gen(rd());
84 std::normal_distribution<>
d(mean, var);
86 for (
int i = 0; i < n; i++)
88 v.push_back( d(gen) );
101 std::random_device rd;
102 std::mt19937 gen(rd());
103 std::normal_distribution<>
d(mean, var);
105 std::map<int, int> hist;
106 for(
int n=0; n<10000; ++n)
108 ++hist[std::round(d(gen))];
112 std::cout << std::fixed << std::setprecision(1) << std::setw(2)
113 << p.first <<
' ' << std::string(p.second/200,
'*') <<
'\n';
Gaussian(double mean, double variance)
boost::shared_ptr< Gaussian > GaussianPtr
float sampleRandomValue()
void sampleRandomValues(std::vector< float > &v, int n)