Random numbers: Difference between revisions

Line 182:
public:
normal_distribution(double m, double s): mu(m), sigma(s) {}
double operator() const // returns a single normally distributed number
{
double r1 = (std::rand() + 1.0)/(RAND_MAX + 1.0); // gives equal distribution in (0, 1]
Line 189:
}
private:
const double mu, sigma;
};
 
Line 226:
</lang>
 
{{works with|C++11}}
'''C++0x'''
 
The new C++ standard looks very similar to the Boost library here.
Line 245:
vector<double> v(1000);
generate(v.begin(), v.end(), rnd);
return 0;
}</lang>
 
Anonymous user