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

 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
3053  : _Par(_T0, _P0)
3054  { // construct
3055  }
param_type _Par
Definition: random:3171
template<class _Ty = int>
binomial_distribution< _Ty >::binomial_distribution ( const param_type _Par0)
inlineexplicit
3058  : _Par(_Par0)
3059  { // construct from parameter package
3060  }
param_type _Par
Definition: random:3171

Member Function Documentation

template<class _Ty = int>
template<class _Engine >
result_type binomial_distribution< _Ty >::_Eval ( _Engine &  _Eng,
const param_type _Par0 
) const
inlineprivate
3134  { // Press et al., Numerical Recipes in C, 2nd ed., pp 295-296.
3135  _Ty _Res;
3136  if (_Par0._Tx < 25)
3137  { // generate directly
3138  _Res = 0;
3139  for (_Ty _Ix = 0; _Ix < _Par0._Tx; ++_Ix)
3140  if (_NRAND(_Eng, _Ty1) < _Par0._Px)
3141  ++_Res;
3142  return (_Res);
3143  }
3144  else if (_Par0._Mean < 1.0)
3145  // events are rare, use Poisson distribution
3146  _Res = _Par0._Small(_Eng);
3147  else
3148  { // no shortcuts
3149  for (; ; )
3150  { // generate and reject
3151  _Ty1 _Yx;
3152  for (; ; )
3153  { // generate a tentative value
3154  _Yx = (_Ty1)_CSTD tan(_Pi * _NRAND(_Eng, _Ty1));
3155  _Res = (_Ty)(_Par0._Sqrt * _Yx + _Par0._Mean);
3156  if (static_cast<_Ty>(0) <= _Res && _Res <= _Par0._Tx)
3157  break;
3158  }
3159  if (_NRAND(_Eng, _Ty1) <= 1.2 * _Par0._Sqrt
3160  * (1.0 + _Yx * _Yx)
3161  * _CSTD exp(_Par0._G1 - _XLgamma(_Res + 1.0)
3162  - _XLgamma(_Par0._Tx - _Res
3163  + 1.0) + _Res * _Par0._Logp
3164  + (_Par0._Tx - _Res) * _Par0._Logp1))
3165  break;
3166  }
3167  }
3168  return (_Par0._Px == _Par0._Pp ? _Res : (_Par0._Tx - _Res));
3169  }
static constexpr long double _Pi
Definition: random:77
_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:323
#define _CSTD
Definition: yvals.h:570
double _Ty1
Definition: random:2985
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
3112  { // read state from _Istr
3113  _Ty _T0;
3114  _Ty1 _P0;
3115  _In(_Istr, _P0);
3116  _In(_Istr, _T0);
3117  _Par._Init(_T0, _P0);
3118  return (_Istr);
3119  }
param_type _Par
Definition: random:3171
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:133
double _Ty1
Definition: random:2985
void _Init(_Ty _T0, _Ty1 _P0)
Definition: random:3021
template<class _Ty = int>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& binomial_distribution< _Ty >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
3125  { // write state to _Ostr
3126  _Out(_Ostr, _Par._Px);
3127  _Out(_Ostr, _Par._Tx);
3128  return (_Ostr);
3129  }
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:151
_Ty1 _Px
Definition: random:3039
_Ty _Tx
Definition: random:3038
param_type _Par
Definition: random:3171
template<class _Ty = int>
result_type() binomial_distribution< _Ty >::max ( ) const
inline
3088  { // get largest possible result
3089  return (_Par.t());
3090  }
_Ty t() const
Definition: random:3011
param_type _Par
Definition: random:3171
template<class _Ty = int>
result_type() binomial_distribution< _Ty >::min ( ) const
inline
3083  { // get smallest possible result
3084  return (0);
3085  }
template<class _Ty = int>
template<class _Engine >
result_type binomial_distribution< _Ty >::operator() ( _Engine &  _Eng) const
inline
3098  { // return next value
3099  return (_Eval(_Eng, _Par));
3100  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:3133
param_type _Par
Definition: random:3171
template<class _Ty = int>
template<class _Engine >
result_type binomial_distribution< _Ty >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
3104  { // return next value, given parameter package
3105  return (_Eval(_Eng, _Par0));
3106  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:3133
template<class _Ty = int>
_Ty1 binomial_distribution< _Ty >::p ( ) const
inline
3068  { // return probability
3069  return (_Par.p());
3070  }
_Ty1 p() const
Definition: random:3016
param_type _Par
Definition: random:3171
template<class _Ty = int>
param_type binomial_distribution< _Ty >::param ( ) const
inline
3073  { // return parameter package
3074  return (_Par);
3075  }
param_type _Par
Definition: random:3171
template<class _Ty = int>
void binomial_distribution< _Ty >::param ( const param_type _Par0)
inline
3078  { // set parameter package
3079  _Par = _Par0;
3080  }
param_type _Par
Definition: random:3171
template<class _Ty = int>
void binomial_distribution< _Ty >::reset ( )
inline
3093  { // clear internal state
3094  }
template<class _Ty = int>
_Ty binomial_distribution< _Ty >::t ( ) const
inline
3063  { // return max value
3064  return (_Par.t());
3065  }
_Ty t() const
Definition: random:3011
param_type _Par
Definition: random:3171

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: