#
A discrete_distribution random number distribution produces random integers i,
2
#
Unless specified otherwise, the distribution parameters are calculated as:
Moreover, the following relation shall hold:
namespace std { template<class IntType = int> class discrete_distribution { public: / types using result_type = IntType; using param_type = unspecified; / constructor and reset functions discrete_distribution(); template<class InputIterator> discrete_distribution(InputIterator firstW, InputIterator lastW); discrete_distribution(initializer_list<double> wl); template<class UnaryOperation> discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw); explicit discrete_distribution(const param_type& parm); void reset(); / equality operators friend bool operator=(const discrete_distribution& x, const discrete_distribution& y); / generating functions template<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); / property functions vector<double> probabilities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; / inserters and extractors template<class charT, class traits> friend basic_ostream<charT, traits>& operator<(basic_ostream<charT, traits>& os, const discrete_distribution& x); template<class charT, class traits> friend basic_istream<charT, traits>& operator>(basic_istream<charT, traits>& is, discrete_distribution& x); }; }
discrete_distribution();
Effects: Constructs a discrete_distribution object with
[Note 1: 
Such an object will always deliver the value 0.
— end note]
template<class InputIterator> discrete_distribution(InputIterator firstW, InputIterator lastW);
Mandates: is_convertible_v<iterator_traits<InputIterator>​::​value_type, double> is true.
Preconditions: InputIterator meets the Cpp17InputIterator requirements ([input.iterators]).
If firstW == lastW, let
Otherwise, [firstW, lastW) forms a sequence w of length
Effects: Constructs a discrete_distribution object with probabilities given by the Formula 29.19.
discrete_distribution(initializer_list<double> wl);
Effects: Same as discrete_distribution(wl.begin(), wl.end().
template<class UnaryOperation> discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw);
Preconditions: If
The relation
Effects: Constructs a discrete_distribution object with probabilities given by the formula above, using the following values: If
Otherwise, let
Complexity: The number of invocations of fw does not exceed n.
vector<double> probabilities() const;
Returns: A vector<double> whose size member returns n and whose operator[] member returns

29.5.9.6.2 Class template piecewise_constant_distribution [rand.dist.samp.pconst]

A piecewise_constant_distribution random number distribution produces random numbers x,
The
Unless specified otherwise, the remaining n distribution parameters are calculated as:
Moreover, the following relation shall hold:
namespace std { template<class RealType = double> class piecewise_constant_distribution { public: / types using result_type = RealType; using param_type = unspecified; / constructor and reset functions piecewise_constant_distribution(); template<class InputIteratorB, class InputIteratorW> piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template<class UnaryOperation> piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw); template<class UnaryOperation> piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); explicit piecewise_constant_distribution(const param_type& parm); void reset(); / equality operators friend bool operator=(const piecewise_constant_distribution& x, const piecewise_constant_distribution& y); / generating functions template<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); / property functions vector<result_type> intervals() const; vector<result_type> densities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; / inserters and extractors template<class charT, class traits> friend basic_ostream<charT, traits>& operator<(basic_ostream<charT, traits>& os, const piecewise_constant_distribution& x); template<class charT, class traits> friend basic_istream<charT, traits>& operator>(basic_istream<charT, traits>& is, piecewise_constant_distribution& x); }; }
piecewise_constant_distribution();
Effects: Constructs a piecewise_constant_distribution object with
template<class InputIteratorB, class InputIteratorW> piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW);
Mandates: Both of
  • is_convertible_v<iterator_traits<InputIteratorB>​::​value_type, double>
  • is_convertible_v<iterator_traits<InputIteratorW>​::​value_type, double>
are true.
Preconditions: InputIteratorB and InputIteratorW each meet the Cpp17InputIterator requirements ([input.iterators]).
If firstB == lastB or ++firstB == lastB, let
Otherwise, [firstB, lastB) forms a sequence b of length
Effects: Constructs a piecewise_constant_distribution object with parameters as specified above.
template<class UnaryOperation> piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);
Effects: Constructs a piecewise_constant_distribution object with parameters taken or calculated from the following values: If
Otherwise, let [bl.begin(), bl.end()) form a sequence
Complexity: The number of invocations of fw does not exceed n.
template<class UnaryOperation> piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
Preconditions: If
The relation
Effects: Constructs a piecewise_constant_distribution object with parameters taken or calculated from the following values: Let
Complexity: The number of invocations of fw does not exceed n.
vector<result_type> intervals() const;
Returns: A vector<result_type> whose size member returns
vector<result_type> densities() const;
Returns: A vector<result_type> whose size member returns n and whose operator[] member returns

29.5.9.6.3 Class template piecewise_linear_distribution [rand.dist.samp.plinear]

A piecewise_linear_distribution random number distribution produces random numbers x,
The
Unless specified otherwise, the remaining
Moreover, the following relation shall hold:
namespace std { template<class RealType = double> class piecewise_linear_distribution { public: / types using result_type = RealType; using param_type = unspecified; / constructor and reset functions piecewise_linear_distribution(); template<class InputIteratorB, class InputIteratorW> piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW); template<class UnaryOperation> piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw); template<class UnaryOperation> piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); explicit piecewise_linear_distribution(const param_type& parm); void reset(); / equality operators friend bool operator=(const piecewise_linear_distribution& x, const piecewise_linear_distribution& y); / generating functions template<class URBG> result_type operator()(URBG& g); template<class URBG> result_type operator()(URBG& g, const param_type& parm); / property functions vector<result_type> intervals() const; vector<result_type> densities() const; param_type param() const; void param(const param_type& parm); result_type min() const; result_type max() const; / inserters and extractors template<class charT, class traits> friend basic_ostream<charT, traits>& operator<(basic_ostream<charT, traits>& os, const piecewise_linear_distribution& x); template<class charT, class traits> friend basic_istream<charT, traits>& operator>(basic_istream<charT, traits>& is, piecewise_linear_distribution& x); }; }
piecewise_linear_distribution();
Effects: Constructs a piecewise_linear_distribution object with
template<class InputIteratorB, class InputIteratorW> piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW);
Mandates: Both of
  • is_convertible_v<iterator_traits<InputIteratorB>​::​value_type, double>
  • is_convertible_v<iterator_traits<InputIteratorW>​::​value_type, double>
are true.
Preconditions: InputIteratorB and InputIteratorW each meet the Cpp17InputIterator requirements ([input.iterators]).
If firstB == lastB or ++firstB == lastB, let
Otherwise, [firstB, lastB) forms a sequence b of length
Effects: Constructs a piecewise_linear_distribution object with parameters as specified above.
template<class UnaryOperation> piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);
Effects: Constructs a piecewise_linear_distribution object with parameters taken or calculated from the following values: If
Otherwise, let [bl.begin(), bl.end()) form a sequence
Complexity: The number of invocations of fw does not exceed
template<class UnaryOperation> piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw);
Preconditions: If
The relation
Effects: Constructs a piecewise_linear_distribution object with parameters taken or calculated from the following values: Let
Complexity: The number of invocations of fw does not exceed
vector<result_type> intervals() const;
Returns: A vector<result_type> whose size member returns
vector<result_type> densities() const;
Returns: A vector<result_type> whose size member returns n and whose operator[] member returns

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant