Boost logo

Boost Users :

Subject: Re: [Boost-users] [Math/Statistical Distributions+Random] Random number generation
From: er (erwann.rogard_at_[hidden])
Date: 2009-04-17 19:26:36


Marco Guazzone wrote:

>
> This would be a good starting point, even if the resulting code might
> be penalized in performance and resource consumption (e.g., for the

... and here it is :

typedef math::exponential_distribution<value_type> dexp_t;

typedef exponential_distribution<value_type> rexp_t;
typedef variate_generator<urng_t&, rexp_t> gen_t;

nn = 1e2;
boost::random::make_variate_generator(urng,dexp); //t0
std::generate_n(back_inserter(vec),nn,random::make_variate_generator(urng,dexp));
//t2
gen_t gen(urng,rexp); //t1
std::generate_n(back_inserter(vec),nn,gen_t(urng,rexp));//t3

time per 1000000 iterations :
t0 = 1.54508 t1 = 1.49743 t2 = 5.95946 t3 = 5.91909


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net