C++ Gamma Distribution History

From FultonWiki
Jump to navigation Jump to search

Jens Maurer proposed the Extended Random Number Facility addition to the standard library in 2002. In Document 1398, proposed after the Oxford meeting, he suggested an extension to the library with a variety of random number generators, including this proposal for gamma distributions:

namespace std {
  template<class RealType = double>
  class gamma_distribution
  {
  public:
    // types
    typedef RealType input_type;
    typedef RealType result_type;

    //  constructors and member function
    explicit gamma_distribution(const result_type& alpha = result_type(1));
    RealType alpha() const;
    void reset();
    template<class UniformRandomNumberGenerator>
    result_type operator()(UniformRandomNumberGenerator& urng);
  };
}

"A gamma_distribution random distribution produces random numbers x distributed with probability density function p(x) = 1/Gamma(alpha) * xalpha-1 * exp(-x), where alpha is the parameter of the distribution."

This proposal did not include any kind of scale or rate parameter. It went through a few additional revisions, including documents WG21/N1914 (2005) and WG21/N1932 and N1933 (2006). Then, in the Berlin meeting that year, the proposal was updated as WG21/N2032:

 This document revises N1932 = Brown, et al.: Random Number Generation in C++0X: A Comprehensive Proposal.
 It incorporates all known corrections to that paper’s language and typography, including all emendations requested by the
 Library Working Group during its Berlin meeting (3–7 April, 2006). and also adopts the context of N2009 = Becker:
 Working Draft, Standard for Programming Language C++. Changes in wording from the previous version of this
 paper are indicated as either added or deleted text.


In this document, the gamma distribution was modified as follows:

template <class RealType = double>
class gamma_distribution
{
  public:
  // types
  typedef RealType result_type;
  typedef unspecified param_type;

  // constructors and reset functions
  explicit gamma_distribution(RealType alpha = 1.0, RealType beta = 1.0);
  explicit gamma_distribution(const param_type& parm);
  void reset();

  // generating functions
  template <class UniformRandomNumberGenerator>
    result_type operator()(UniformRandomNumberGenerator& urng);

  template <class UniformRandomNumberGenerator>
    result_type operator()(UniformRandomNumberGenerator& urng, const param_type& parm);
  
  // property functions
  RealType alpha() const;
  RealType beta() const;
  param_type param() const;
  void param(const param_type& parm);
  result_type min() const;
  result_type max() const;
};

No record seems to indicate the decision to use beta as the name of the scale/rate parameter, but this seems to be the version that was accepted into the C++11 standard.