Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::random::binomial_distribution< IntType, RealType > Class Template Reference

The binomial distribution is an integer valued distribution with two parameters, t and p. More...

#include <binomial_distribution.hpp>

Classes

class  param_type
 

Public Types

typedef IntType result_type
 
typedef RealType input_type
 

Public Member Functions

 binomial_distribution (IntType t_arg=1, RealType p_arg=RealType(0.5))
 Construct a binomial_distribution object. More...
 
 binomial_distribution (const param_type &parm)
 Construct an binomial_distribution object from the parameters. More...
 
template<class URNG >
IntType operator() (URNG &urng) const
 Returns a random variate distributed according to the binomial distribution. More...
 
template<class URNG >
IntType operator() (URNG &urng, const param_type &parm) const
 Returns a random variate distributed according to the binomial distribution with parameters specified by param. More...
 
IntType t () const
 Returns the t parameter of the distribution. More...
 
RealType p () const
 Returns the p parameter of the distribution. More...
 
IntType min BOOST_PREVENT_MACRO_SUBSTITUTION () const
 Returns the smallest value that the distribution can produce. More...
 
IntType max BOOST_PREVENT_MACRO_SUBSTITUTION () const
 Returns the largest value that the distribution can produce. More...
 
param_type param () const
 Returns the parameters of the distribution. More...
 
void param (const param_type &parm)
 Sets parameters of the distribution. More...
 
void reset ()
 Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset. More...
 

Friends

template<class CharT , class Traits >
std::basic_ostream< CharT,
Traits > & 
operator<< (std::basic_ostream< CharT, Traits > &os, const binomial_distribution &bd)
 Writes the parameters of the distribution to a std::ostream. More...
 
template<class CharT , class Traits >
std::basic_istream< CharT,
Traits > & 
operator>> (std::basic_istream< CharT, Traits > &is, binomial_distribution &bd)
 Reads the parameters of the distribution from a std::istream. More...
 
bool operator== (const binomial_distribution &lhs, const binomial_distribution &rhs)
 Returns true if the two distributions will produce the same sequence of values, given equal generators. More...
 
bool operator!= (const binomial_distribution &lhs, const binomial_distribution &rhs)
 Returns true if the two distributions could produce different sequences of values, given equal generators. More...
 

Detailed Description

template<class IntType = int, class RealType = double>
class boost::random::binomial_distribution< IntType, RealType >

The binomial distribution is an integer valued distribution with two parameters, t and p.

The values of the distribution are within the range [0,t].

The distribution function is $\displaystyle P(k) = {t \choose k}p^k(1-p)^{t-k}$.

The algorithm used is the BTRD algorithm described in

"The generation of binomial random variates", Wolfgang Hormann, Journal of Statistical Computation and Simulation, Volume 46, Issue 1 & 2 April 1993 , pages 101 - 110

Member Typedef Documentation

template<class IntType = int, class RealType = double>
typedef RealType boost::random::binomial_distribution< IntType, RealType >::input_type
template<class IntType = int, class RealType = double>
typedef IntType boost::random::binomial_distribution< IntType, RealType >::result_type

Constructor & Destructor Documentation

template<class IntType = int, class RealType = double>
boost::random::binomial_distribution< IntType, RealType >::binomial_distribution ( IntType  t_arg = 1,
RealType  p_arg = RealType(0.5) 
)
inlineexplicit

Construct a binomial_distribution object.

t and p are the parameters of the distribution.

Requires: t >=0 && 0 <= p <= 1

References boost::unit_test::framework::init().

Referenced by boost::random::binomial_distribution< IntType, RealType >::operator()().

template<class IntType = int, class RealType = double>
boost::random::binomial_distribution< IntType, RealType >::binomial_distribution ( const param_type parm)
inlineexplicit

Construct an binomial_distribution object from the parameters.

References boost::unit_test::framework::init().

Member Function Documentation

template<class IntType = int, class RealType = double>
IntType min boost::random::binomial_distribution< IntType, RealType >::BOOST_PREVENT_MACRO_SUBSTITUTION ( ) const
inline

Returns the smallest value that the distribution can produce.

template<class IntType = int, class RealType = double>
IntType max boost::random::binomial_distribution< IntType, RealType >::BOOST_PREVENT_MACRO_SUBSTITUTION ( ) const
inline

Returns the largest value that the distribution can produce.

References boost::phoenix::local_names::_t.

template<class IntType = int, class RealType = double>
template<class URNG >
IntType boost::random::binomial_distribution< IntType, RealType >::operator() ( URNG &  urng) const
inline

Returns a random variate distributed according to the binomial distribution.

References boost::phoenix::local_names::_p, boost::phoenix::local_names::_t, boost::range::generate(), and boost::iostreams::grep::invert.

template<class IntType = int, class RealType = double>
template<class URNG >
IntType boost::random::binomial_distribution< IntType, RealType >::operator() ( URNG &  urng,
const param_type parm 
) const
inline

Returns a random variate distributed according to the binomial distribution with parameters specified by param.

References boost::random::binomial_distribution< IntType, RealType >::binomial_distribution().

template<class IntType = int, class RealType = double>
RealType boost::random::binomial_distribution< IntType, RealType >::p ( ) const
inline

Returns the p parameter of the distribution.

References boost::phoenix::local_names::_p.

template<class IntType = int, class RealType = double>
param_type boost::random::binomial_distribution< IntType, RealType >::param ( ) const
inline

Returns the parameters of the distribution.

References boost::phoenix::local_names::_p, and boost::phoenix::local_names::_t.

template<class IntType = int, class RealType = double>
void boost::random::binomial_distribution< IntType, RealType >::reset ( void  )
inline

Effects: Subsequent uses of the distribution do not depend on values produced by any engine prior to invoking reset.

template<class IntType = int, class RealType = double>
IntType boost::random::binomial_distribution< IntType, RealType >::t ( ) const
inline

Returns the t parameter of the distribution.

References boost::phoenix::local_names::_t.

Friends And Related Function Documentation

template<class IntType = int, class RealType = double>
bool operator!= ( const binomial_distribution< IntType, RealType > &  lhs,
const binomial_distribution< IntType, RealType > &  rhs 
)
friend

Returns true if the two distributions could produce different sequences of values, given equal generators.

template<class IntType = int, class RealType = double>
template<class CharT , class Traits >
std::basic_ostream<CharT,Traits>& operator<< ( std::basic_ostream< CharT, Traits > &  os,
const binomial_distribution< IntType, RealType > &  bd 
)
friend

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

template<class IntType = int, class RealType = double>
bool operator== ( const binomial_distribution< IntType, RealType > &  lhs,
const binomial_distribution< IntType, RealType > &  rhs 
)
friend

Returns true if the two distributions will produce the same sequence of values, given equal generators.

template<class IntType = int, class RealType = double>
template<class CharT , class Traits >
std::basic_istream<CharT,Traits>& operator>> ( std::basic_istream< CharT, Traits > &  is,
binomial_distribution< IntType, RealType > &  bd 
)
friend

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


The documentation for this class was generated from the following file: