[Boost-bugs] [Boost C++ Libraries] #3888: Generation of two-parameter Gamma variates

Subject: [Boost-bugs] [Boost C++ Libraries] #3888: Generation of two-parameter Gamma variates
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-02-01 17:15:50


#3888: Generation of two-parameter Gamma variates
-------------------------------------------------------+--------------------
 Reporter: Marco Guazzone <marco.guazzone@…> | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: random
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |
-------------------------------------------------------+--------------------
 Actually, the code used to generate random Gamma variates cannot be
 used to generate variates for two-parameters Gamma distributions, that is
 for Gamma distributions with both shape and scale parameters
 (e.g., see [http://en.wikipedia.org/wiki/Gamma_distribution] or
 [http://www.itl.nist.gov/div898/handbook/eda/section3/eda366b.htm]).

 In principle this should be possible by means of the ''scaling property'':
 '''Gamma(shape,scale) ~ scale*Gamma(shape,1)'''

 This would simply translate into

 {{{
 boost::mt19937 rng;
 boost::gamma_distribution<> gamma(shape); // 1-parameter Gamma
 distribution
 boost::variate_generator< boost::mt19937&, boost::gamma_distribution<> >
 rvg(rng, gamma);
 double r = scale*rvg();
 }}}


 However, when ''shape == 1'' the implementation uses the fact that
 '''Gamma(1) ~ Exp(1)'''.
 This is rigth when ''scale==1'' but not when ''scale != 1'' since the
 exact relation is
 '''Gamma(1,scale) ~ Exp(1/scale)'''

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3888>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC