cocomice
11/5/2014 - 11:43 PM

Boost Random Generators

Boost Random Generators


// requires the boost library and inclueded in the hearder ;

double Random_Log(double mi, double sigma)
{
  boost::mt19937 rng(43);
  boost::lognormal_distribution<double> lnd(mi, sigma);
  boost::variate_generator<boost::mt19937&, boost::lognormal_distribution<> > var_lognor(rng, lnd);
  return var_lognor();
}

double lognpdf(double val, double mi, double sigma)
{
  boost::math::lognormal_distribution<double> d(mi, sigma);
  return boost::math::pdf(d, val) ;
}