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< _Ty0, _Ty1 > Class Template Reference

Classes

struct  param_type
 

Public Types

typedef binomial_distribution< _Ty0, _Ty1 > _Myt
 
typedef _Ty1 input_type
 
typedef _Ty0 result_type
 

Public Member Functions

 binomial_distribution (_Ty0 _T0=1, _Ty1 _P0=_Ty1(0.5))
 
 binomial_distribution (param_type _Par0)
 
_Ty0 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 _Ty0 = int, class _Ty1 = double>
typedef binomial_distribution<_Ty0, _Ty1> binomial_distribution< _Ty0, _Ty1 >::_Myt
template<class _Ty0 = int, class _Ty1 = double>
typedef _Ty1 binomial_distribution< _Ty0, _Ty1 >::input_type
template<class _Ty0 = int, class _Ty1 = double>
typedef _Ty0 binomial_distribution< _Ty0, _Ty1 >::result_type

Constructor & Destructor Documentation

template<class _Ty0 = int, class _Ty1 = double>
binomial_distribution< _Ty0, _Ty1 >::binomial_distribution ( _Ty0  _T0 = 1,
_Ty1  _P0 = _Ty1(0.5) 
)
inlineexplicit
3374  : _Par(_T0, _P0)
3375  { // construct
3376  }
param_type _Par
Definition: random:3493
template<class _Ty0 = int, class _Ty1 = double>
binomial_distribution< _Ty0, _Ty1 >::binomial_distribution ( param_type  _Par0)
inlineexplicit
3379  : _Par(_Par0)
3380  { // construct from parameter package
3381  }
param_type _Par
Definition: random:3493

Member Function Documentation

template<class _Ty0 = int, class _Ty1 = double>
template<class _Engine >
result_type binomial_distribution< _Ty0, _Ty1 >::_Eval ( _Engine &  _Eng,
const param_type _Par0 
) const
inlineprivate
3455  { // Press et al., Numerical Recipes in C, 2nd ed., pp 295-296.
3456  _Ty0 _Res;
3457  static _Ty0 _Zero = 0; // to quiet diagnostics
3458  if (_Par0._Tx < 25)
3459  { // generate directly
3460  _Res = 0;
3461  for (_Ty0 _Ix = 0; _Ix < _Par0._Tx; ++_Ix)
3462  if (_NRAND(_Eng, _Ty1) < _Par0._Px)
3463  ++_Res;
3464  return (_Res);
3465  }
3466  else if (_Par0._Mean < 1.0)
3467  // events are rare, use Poisson distribution
3468  return (_Par0._Small(_Eng));
3469  else
3470  { // no shortcuts
3471  for (; ; )
3472  { // generate and reject
3473  _Ty1 _Yx;
3474  for (; ; )
3475  { // generate a tentative value
3476  _Yx = (_Ty1)_CSTD tan(_Pi * _NRAND(_Eng, _Ty1));
3477  _Res = (_Ty0)(_Par0._Sqrt * _Yx + _Par0._Mean);
3478  if (_Zero <= _Res && _Res <= _Par0._Tx)
3479  break;
3480  }
3481  if (_NRAND(_Eng, _Ty1) <= 1.2 * _Par0._Sqrt
3482  * (1.0 + _Yx * _Yx)
3483  * _CSTD exp(_Par0._G1 - _XLgamma(_Res + 1.0)
3484  - _XLgamma(_Par0._Tx - _Res
3485  + 1.0) + _Res * _Par0._Logp
3486  + (_Par0._Tx - _Res) * _Par0._Logp1))
3487  break;
3488  }
3489  return (_Par0._Px == _Par0._Pp ? _Res : (_Par0._Tx - _Res));
3490  }
3491  }
_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:74
static const long double _Pi
Definition: random:62
#define _CSTD
Definition: yvals.h:559
float tan(float _X) __GPU_ONLY
Calculates the tangent value of the argument
Definition: amp_math.h:1128
template<class _Ty0 = int, class _Ty1 = double>
template<class _Elem , class _Traits >
basic_istream<_Elem, _Traits>& binomial_distribution< _Ty0, _Ty1 >::_Read ( basic_istream< _Elem, _Traits > &  _Istr)
inline
3433  { // read state from _Istr
3434  _Ty0 _T0;
3435  _Ty1 _P0;
3436  _In(_Istr, _P0);
3437  _In(_Istr, _T0);
3438  _Par._Init(_T0, _P0);
3439  return (_Istr);
3440  }
param_type _Par
Definition: random:3493
void _Init(_Ty0 _T0, _Ty1 _P0)
Definition: random:3344
basic_istream< _Elem, _Traits > & _In(basic_istream< _Elem, _Traits > &_Is, _Ty &_Dx)
Definition: random:151
template<class _Ty0 = int, class _Ty1 = double>
template<class _Elem , class _Traits >
basic_ostream<_Elem, _Traits>& binomial_distribution< _Ty0, _Ty1 >::_Write ( basic_ostream< _Elem, _Traits > &  _Ostr) const
inline
3446  { // write state to _Ostr
3447  _Out(_Ostr, _Par._Px);
3448  _Out(_Ostr, _Par._Tx);
3449  return (_Ostr);
3450  }
_Ty1 _Px
Definition: random:3362
param_type _Par
Definition: random:3493
basic_ostream< _Elem, _Traits > & _Out(basic_ostream< _Elem, _Traits > &_Os, _Ty _Dx)
Definition: random:169
_Ty0 _Tx
Definition: random:3361
template<class _Ty0 = int, class _Ty1 = double>
result_type() binomial_distribution< _Ty0, _Ty1 >::max ( ) const
inline
3409  { // get largest possible result
3410  return ((numeric_limits<result_type>::max)());
3411  }
Definition: limits:79
template<class _Ty0 = int, class _Ty1 = double>
result_type() binomial_distribution< _Ty0, _Ty1 >::min ( ) const
inline
3404  { // get smallest possible result
3405  return (0);
3406  }
template<class _Ty0 = int, class _Ty1 = double>
template<class _Engine >
result_type binomial_distribution< _Ty0, _Ty1 >::operator() ( _Engine &  _Eng) const
inline
3419  { // return next value
3420  return (_Eval(_Eng, _Par));
3421  }
param_type _Par
Definition: random:3493
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:3454
template<class _Ty0 = int, class _Ty1 = double>
template<class _Engine >
result_type binomial_distribution< _Ty0, _Ty1 >::operator() ( _Engine &  _Eng,
const param_type _Par0 
) const
inline
3425  { // return next value, given parameter package
3426  return (_Eval(_Eng, _Par0));
3427  }
result_type _Eval(_Engine &_Eng, const param_type &_Par0) const
Definition: random:3454
template<class _Ty0 = int, class _Ty1 = double>
_Ty1 binomial_distribution< _Ty0, _Ty1 >::p ( ) const
inline
3389  { // return probability
3390  return (_Par.p());
3391  }
param_type _Par
Definition: random:3493
_Ty1 p() const
Definition: random:3339
template<class _Ty0 = int, class _Ty1 = double>
param_type binomial_distribution< _Ty0, _Ty1 >::param ( ) const
inline
3394  { // return parameter package
3395  return (_Par);
3396  }
param_type _Par
Definition: random:3493
template<class _Ty0 = int, class _Ty1 = double>
void binomial_distribution< _Ty0, _Ty1 >::param ( const param_type _Par0)
inline
3399  { // set parameter package
3400  _Par = _Par0;
3401  }
param_type _Par
Definition: random:3493
template<class _Ty0 = int, class _Ty1 = double>
void binomial_distribution< _Ty0, _Ty1 >::reset ( )
inline
3414  { // clear internal state
3415  }
template<class _Ty0 = int, class _Ty1 = double>
_Ty0 binomial_distribution< _Ty0, _Ty1 >::t ( ) const
inline
3384  { // return max value
3385  return (_Par.t());
3386  }
param_type _Par
Definition: random:3493
_Ty0 t() const
Definition: random:3334

Member Data Documentation

template<class _Ty0 = int, class _Ty1 = double>
param_type binomial_distribution< _Ty0, _Ty1 >::_Par
private

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