STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
binomial_distribution< _Ty > Class Template Reference

Classes

struct  param_type
 

Public Types

typedef binomial_distribution< _Ty > _Myt
 
typedef double _Ty1
 
typedef _Ty result_type
 

Public Member Functions

 _RNG_REQUIRE_INTTYPE (binomial_distribution, _Ty)
 
 binomial_distribution (_Ty _T0=1, _Ty1 _P0=_Ty1(0.5))
 
 binomial_distribution (const param_type &_Par0)
 
_Ty t () const
 
_Ty1 p () const
 
param_type param () const
 
void param (const param_type &_Par0)
 
result_type() min () const
 
result_type() max () const
 
void reset ()
 
template<class _Engine >
result_type operator() (_Engine &_Eng) const
 
template<class _Engine >
result_type operator() (_Engine &_Eng, const param_type &_Par0) const
 
template<class _Elem , class _Traits >
basic_istream< _Elem, _Traits > & _Read (basic_istream< _Elem, _Traits > &_Istr)
 
template<class _Elem , class _Traits >
basic_ostream< _Elem, _Traits > & _Write (basic_ostream< _Elem, _Traits > &_Ostr) const
 

Private Member Functions

template<class _Engine >
result_type _Eval (_Engine &_Eng, const param_type &_Par0) const
 

Private Attributes

param_type _Par
 

Member Typedef Documentation

template<class _Ty = int>
typedef binomial_distribution<_Ty> binomial_distribution< _Ty >::_Myt
template<class _Ty = int>
typedef double binomial_distribution< _Ty >::_Ty1
template<class _Ty = int>
typedef _Ty binomial_distribution< _Ty >::result_type

Constructor & Destructor Documentation

template<class _Ty = int>
binomial_distribution< _Ty >::binomial_distribution ( _Ty  _T0 = 1,
_Ty1  _P0 = _Ty1(0.5) 
)
inlineexplicit
3083  : _Par(_T0, _P0)
3084  { // construct
3085  }
param_type _Par
Definition: random:3201
template<class _Ty = int>
binomial_distribution< _Ty >::binomial_distribution ( const param_type _Par0)
inlineexplicit
3088  : _Par(_Par0)
3089  { // construct from parameter package
3090  }
param_type _Par
Definition: random:3201

Member Function Documentation

template<class _Ty = int>
template<class _Engine >
result_type binomial_distribution< _Ty >::_Eval ( _Engine &  _Eng,
const param_type _Par0 
) const
inlineprivate
3164  { // Press et al., Numerical Recipes in C, 2nd ed., pp 295-296.
3165  _Ty _Res;
3166  if (_Par0._Tx < 25)
3167  { // generate directly
3168  _Res = 0;
3169  for (_Ty _Ix = 0; _Ix < _Par0._Tx; ++_Ix)
3170  if (_NRAND(_Eng, _Ty1) < _Par0._Px)
3171  ++_Res;
3172  return (_Res);
3173  }
3174  else if (_Par0._Mean < 1.0)
3175  // events are rare, use Poisson distribution
3176  _Res = _Par0._Small(_Eng);
3177  else
3178  { // no shortcuts
3179  for (; ; )
3180  { // generate and reject
3181  _Ty1 _Yx;
3182  for (; ; )
3183  { // generate a tentative value
3184  _Yx = (_Ty1)_CSTD tan(_Pi * _NRAND(_Eng, _Ty1));
3185  _Res = (_Ty)(_Par0._Sqrt * _Yx + _Par0._Mean);
3186  if (static_cast<_Ty>(0) <= _Res && _Res <= _Par0._Tx)
3187  break;
3188  }
3189  if (_NRAND(_Eng, _Ty1) <= 1.2 * _Par0._Sqrt
3190  * (1.0 + _Yx * _Yx)
3191  * _CSTD exp(_Par0._G1 - _XLgamma(_Res + 1.0)
3192  - _XLgamma(_Par0._Tx - _Res
3193  + 1.0) + _Res * _Par0._Logp
3194  + (_Par0._Tx - _Res) * _Par0._Logp1))
3195  break;
3196  }
3197  }
3198  return (_Par0._Px == _Par0._Pp ? _Res : (_Par0._Tx - _Res));
3199  }
constexpr long double _Pi
Definition: random:100
_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _XLgamma(float)
float exp(float _X) __GPU_ONLY
Calculates the base-e exponential of the argument
Definition: amp_math.h:471
#define _NRAND(eng, resty)
Definition: random:345
#define _CSTD
Definition: yvals.h:570
double _Ty1
Definition: random:3016
float tan(float _X) __GPU_ONLY
Calculates the tangent value of the argument
Definition: amp_math.h:1128
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& binomial_distribution< _Ty >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
3142  { // read state from _Istr
3143  _Ty _T0;
3144  _Ty1 _P0;
3145  _In(_Istr, _P0);
3146  _In(_Istr, _T0);
3147  _Par._Init(_T0, _P0);
3148  return (_Istr);
3149  }
param_type _Par
Definition: random:3201
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:156
double _Ty1
Definition: random:3016
void _Init(_Ty _T0, _Ty1 _P0)
Definition: random:3051
template<class _Ty = int>
binomial_distribution< _Ty >::_RNG_REQUIRE_INTTYPE ( binomial_distribution< _Ty >  ,
_Ty   
)
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& binomial_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
3155  { // write state to _Ostr
3156  _Out(_Ostr, _Par._Px);
3157  _Out(_Ostr, _Par._Tx);
3158  return (_Ostr);
3159  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:174
_Ty1 _Px
Definition: random:3069
_Ty _Tx
Definition: random:3068
param_type _Par
Definition: random:3201
template<class _Ty = int>
result_type() binomial_distribution< _Ty >::max ( ) const
inline
3118  { // get largest possible result
3119  return (_Par.t());
3120  }
_Ty t() const
Definition: random:3041
param_type _Par
Definition: random:3201
template<class _Ty = int>
result_type() binomial_distribution< _Ty >::min ( ) const
inline
3113  { // get smallest possible result
3114  return (0);
3115  }
template<class _Ty = int>
template<class _Engine >
result_type binomial_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
3128  { // return next value
3129  return (_Eval(_Eng, _Par));
3130  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:3163
param_type _Par
Definition: random:3201
template<class _Ty = int>
template<class _Engine >
result_type binomial_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
3134  { // return next value, given parameter package
3135  return (_Eval(_Eng, _Par0));
3136  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:3163
template<class _Ty = int>
_Ty1 binomial_distribution< _Ty >::p ( ) const
inline
3098  { // return probability
3099  return (_Par.p());
3100  }
_Ty1 p() const
Definition: random:3046
param_type _Par
Definition: random:3201
template<class _Ty = int>
param_type binomial_distribution< _Ty >::param ( ) const
inline
3103  { // return parameter package
3104  return (_Par);
3105  }
param_type _Par
Definition: random:3201
template<class _Ty = int>
void binomial_distribution< _Ty >::param ( const param_type _Par0)
inline
3108  { // set parameter package
3109  _Par = _Par0;
3110  }
param_type _Par
Definition: random:3201
template<class _Ty = int>
void binomial_distribution< _Ty >::reset ( )
inline
3123  { // clear internal state
3124  }
template<class _Ty = int>
_Ty binomial_distribution< _Ty >::t ( ) const
inline
3093  { // return max value
3094  return (_Par.t());
3095  }
_Ty t() const
Definition: random:3041
param_type _Par
Definition: random:3201

Member Data Documentation

template<class _Ty = int>
param_type binomial_distribution< _Ty >::_Par
private

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