29 Numerics library [numerics]

29.6 Random number generation [rand]

29.6.8 Random number distribution class templates [rand.dist]

29.6.8.3 Bernoulli distributions [rand.dist.bern]

29.6.8.3.1 Class bernoulli_­distribution [rand.dist.bern.bernoulli]

bernoulli_­distribution Распределение случайных чисел производит bool значения , b распределенных в соответствии с дискретной вероятностной функцией

P(b|p)={pifb=true1pifb=false.

class bernoulli_distribution {
public:
  // types
  using result_type = bool;
  using param_type  = unspecified;

  // constructors and reset functions
  explicit bernoulli_distribution(double p = 0.5);
  explicit bernoulli_distribution(const param_type& parm);
  void reset();

  // generating functions
  template<class URBG>
    result_type operator()(URBG& g);
  template<class URBG>
    result_type operator()(URBG& g, const param_type& parm);

  // property functions
  double p() const;
  param_type param() const;
  void param(const param_type& parm);
  result_type min() const;
  result_type max() const;
};

explicit bernoulli_distribution(double p = 0.5);

Requires: 0p1.

Effects: Строит bernoulli_­distribution объект; p соответствует параметру распределения.

double p() const;

Returns: Значение p параметра, с которым был построен объект.