Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit f5a2dc2871.
PrevUpHomeNext

Class template non_central_chi_squared_distribution

boost::random::non_central_chi_squared_distribution

Synopsis

// In header: <boost/random/non_central_chi_squared_distribution.hpp>

template<typename RealType = double> 
class non_central_chi_squared_distribution {
public:
  // types
  typedef RealType result_type;
  typedef RealType input_type; 

  // member classes/structs/unions

  class param_type {
  public:
    // types
    typedef non_central_chi_squared_distribution distribution_type;

    // construct/copy/destruct
    explicit param_type(RealType = 1, RealType = 1);

    // public member functions
    RealType k() const;
    RealType lambda() const;

    // friend functions
    template<typename CharT, typename Traits> 
      std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > &, const param_type &);
    template<typename CharT, typename Traits> 
      std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > &, const param_type &);
    bool operator==(const param_type &, const param_type &);
    bool operator!=(const param_type &, const param_type &);
  };

  // construct/copy/destruct
  explicit non_central_chi_squared_distribution(RealType = 1, RealType = 1);
  explicit non_central_chi_squared_distribution(const param_type &);

  // public member functions
  template<typename URNG> 
    RealType operator()(URNG &, const param_type &) const;
  template<typename URNG> RealType operator()(URNG &);
  RealType k() const;
  RealType lambda() const;
  param_type param() const;
  void param(const param_type &);
  void reset();
  RealType min() const;
  RealType max() const;

  // friend functions
  template<typename CharT, typename Traits> 
    std::basic_ostream< CharT, Traits > & 
    operator<<(std::basic_ostream< CharT, Traits > &, 
               const non_central_chi_squared_distribution &);
  template<typename CharT, typename Traits> 
    std::basic_istream< CharT, Traits > & 
    operator>>(std::basic_istream< CharT, Traits > &, 
               const non_central_chi_squared_distribution &);
  bool operator==(const non_central_chi_squared_distribution &, 
                  const non_central_chi_squared_distribution &);
  bool operator!=(const non_central_chi_squared_distribution &, 
                  const non_central_chi_squared_distribution &);
};

Description

The noncentral chi-squared distribution is a real valued distribution with two parameter, k and lambda. The distribution produces values > 0.

This is the distribution of the sum of squares of k Normal distributed variates each with variance one and the sum of squares of the normal means.

The distribution function is . where is a modified Bessel function of the first kind.

The algorithm is taken from

"Monte Carlo Methods in Financial Engineering", Paul Glasserman, 2003, XIII, 596 p, Stochastic Modelling and Applied Probability, Vol. 53, ISBN 978-0-387-21617-1, p 124, Fig. 3.5.

non_central_chi_squared_distribution public construct/copy/destruct

  1. explicit non_central_chi_squared_distribution(RealType k = 1, 
                                                  RealType lambda = 1);

    Construct a non_central_chi_squared_distribution object. k and lambda are the parameter of the distribution.

    Requires: k > 0 && lambda > 0

  2. explicit non_central_chi_squared_distribution(const param_type & param);

    Construct a non_central_chi_squared_distribution object from the parameter.

non_central_chi_squared_distribution public member functions

  1. template<typename URNG> 
      RealType operator()(URNG & eng, const param_type & param) const;

    Returns a random variate distributed according to the non central chi squared distribution specified by param.

  2. template<typename URNG> RealType operator()(URNG & eng);

    Returns a random variate distributed according to the non central chi squared distribution.

  3. RealType k() const;

    Returns the k parameter of the distribution.

  4. RealType lambda() const;

    Returns the lambda parameter of the distribution.

  5. param_type param() const;

    Returns the parameters of the distribution.

  6. void param(const param_type & param);

    Sets parameters of the distribution.

  7. void reset();

    Resets the distribution, so that subsequent uses does not depend on values already produced by it.

  8. RealType min() const;

    Returns the smallest value that the distribution can produce.

  9. RealType max() const;

    Returns the largest value that the distribution can produce.

non_central_chi_squared_distribution friend functions

  1. template<typename CharT, typename Traits> 
      std::basic_ostream< CharT, Traits > & 
      operator<<(std::basic_ostream< CharT, Traits > & os, 
                 const non_central_chi_squared_distribution & dist);

    Writes the parameters of the distribution to a std::ostream.

  2. template<typename CharT, typename Traits> 
      std::basic_istream< CharT, Traits > & 
      operator>>(std::basic_istream< CharT, Traits > & is, 
                 const non_central_chi_squared_distribution & dist);

    reads the parameters of the distribution from a std::istream.

  3. bool operator==(const non_central_chi_squared_distribution & lhs, 
                    const non_central_chi_squared_distribution & rhs);

    Returns true if two distributions have the same parameters and produce the same sequence of random numbers given equal generators.

  4. bool operator!=(const non_central_chi_squared_distribution & lhs, 
                    const non_central_chi_squared_distribution & rhs);

    Returns true if two distributions have different parameters and/or can produce different sequences of random numbers given equal generators.


PrevUpHomeNext