[rand.dist] (original) (raw)

26 Numerics library [numerics]

26.6 Random number generation [rand]

26.6.8 Random number distribution class templates [rand.dist]

26.6.8.1 In general [rand.dist.general]

Descriptions are provided in this subclause [rand.dist]only for distribution operations that are not described in [rand.req.dist]or for operations where there is additional semantic information.

In particular, declarations for copy constructors, for copy assignment operators, for streaming operators, and for equality and inequality operators are not shown in the synopses.

The algorithms for producing each of the specified distributions areimplementation-defined.

The value of each probability density function p(z)and of each discrete probability function specified in this subclause is 0everywhere outside its stated domain.

26.6.8.2 Uniform distributions [rand.dist.uni]

26.6.8.2.1 Class template uniform_­int_­distribution [rand.dist.uni.int]

A uniform_­int_­distribution random number distribution produces random integers i,, distributed according to the constant discrete probability function

template class uniform_int_distribution { public:

using result_type = IntType;
using param_type  = unspecified;


uniform_int_distribution() : uniform_int_distribution(0) {}
explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());
explicit uniform_int_distribution(const param_type& parm);
void reset();


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


result_type a() const;
result_type b() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit uniform_int_distribution(IntType a, IntType b = numeric_limits<IntType>::max());

Remarks: a and b correspond to the respective parameters of the distribution.

Returns:The value of the a parameter with which the object was constructed.

Returns:The value of the b parameter with which the object was constructed.

26.6.8.2.2 Class template uniform_­real_­distribution [rand.dist.uni.real]

A uniform_­real_­distribution random number distribution produces random numbers x,, distributed according to the constant probability density function

[ Note

:

This implies that is undefined when a == b.

end note

]

template class uniform_real_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


uniform_real_distribution() : uniform_real_distribution(0.0) {}
explicit uniform_real_distribution(RealType a, RealType b = 1.0);
explicit uniform_real_distribution(const param_type& parm);
void reset();


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


result_type a() const;
result_type b() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit uniform_real_distribution(RealType a, RealType b = 1.0);

Remarks: a and b correspond to the respective parameters of the distribution.

Returns:The value of the a parameter with which the object was constructed.

Returns:The value of the b parameter with which the object was constructed.

26.6.8.3 Bernoulli distributions [rand.dist.bern]

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

A bernoulli_­distribution random number distribution produces bool values bdistributed according to the discrete probability function

class bernoulli_distribution { public:

using result_type = bool; using param_type = unspecified;

bernoulli_distribution() : bernoulli_distribution(0.5) {} explicit bernoulli_distribution(double p); explicit bernoulli_distribution(const param_type& parm); void reset();

template result_type operator()(URBG& g); template result_type operator()(URBG& g, const param_type& parm);

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);

Remarks: p corresponds to the parameter of the distribution.

Returns:The value of the p parameter with which the object was constructed.

26.6.8.3.2 Class template binomial_­distribution [rand.dist.bern.bin]

A binomial_­distribution random number distribution produces integer values distributed according to the discrete probability function

template class binomial_distribution { public:

using result_type = IntType;
using param_type  = unspecified;


binomial_distribution() : binomial_distribution(1) {}
explicit binomial_distribution(IntType t, double p = 0.5);
explicit binomial_distribution(const param_type& parm);
void reset();


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


IntType t() const;
double p() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit binomial_distribution(IntType t, double p = 0.5);

Remarks: t and p correspond to the respective parameters of the distribution.

Returns:The value of the t parameter with which the object was constructed.

Returns:The value of the p parameter with which the object was constructed.

26.6.8.3.3 Class template geometric_­distribution [rand.dist.bern.geo]

A geometric_­distribution random number distribution produces integer values distributed according to the discrete probability function

template class geometric_distribution { public:

using result_type = IntType;
using param_type  = unspecified;


geometric_distribution() : geometric_distribution(0.5) {}
explicit geometric_distribution(double p);
explicit geometric_distribution(const param_type& parm);
void reset();


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


double p() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit geometric_distribution(double p);

Remarks: p corresponds to the parameter of the distribution.

Returns:The value of the p parameter with which the object was constructed.

26.6.8.3.4 Class template negative_­binomial_­distribution [rand.dist.bern.negbin]

A negative_­binomial_­distribution random number distribution produces random integers distributed according to the discrete probability function

[ Note

:

This implies that is undefined when p == 1.

end note

]

template class negative_binomial_distribution { public:

using result_type = IntType;
using param_type  = unspecified;


negative_binomial_distribution() : negative_binomial_distribution(1) {}
explicit negative_binomial_distribution(IntType k, double p = 0.5);
explicit negative_binomial_distribution(const param_type& parm);
void reset();


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


IntType k() const;
double p() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit negative_binomial_distribution(IntType k, double p = 0.5);

Remarks: k and p correspond to the respective parameters of the distribution.

Returns:The value of the k parameter with which the object was constructed.

Returns:The value of the p parameter with which the object was constructed.

26.6.8.4 Poisson distributions [rand.dist.pois]

26.6.8.4.1 Class template poisson_­distribution [rand.dist.pois.poisson]

A poisson_­distribution random number distribution produces integer values distributed according to the discrete probability function

The distribution parameter μis also known as this distribution's mean.

template class poisson_distribution { public:

using result_type = IntType;
using param_type  = unspecified;


poisson_distribution() : poisson_distribution(1.0) {}
explicit poisson_distribution(double mean);
explicit poisson_distribution(const param_type& parm);
void reset();


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


double mean() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit poisson_distribution(double mean);

Remarks: mean corresponds to the parameter of the distribution.

Returns:The value of the mean parameter with which the object was constructed.

26.6.8.4.2 Class template exponential_­distribution [rand.dist.pois.exp]

An exponential_­distribution random number distribution produces random numbers distributed according to the probability density function

template class exponential_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


exponential_distribution() : exponential_distribution(1.0) {}
explicit exponential_distribution(RealType lambda);
explicit exponential_distribution(const param_type& parm);
void reset();


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


RealType lambda() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit exponential_distribution(RealType lambda);

Remarks: lambda corresponds to the parameter of the distribution.

Returns:The value of the lambda parameter with which the object was constructed.

26.6.8.4.3 Class template gamma_­distribution [rand.dist.pois.gamma]

A gamma_­distribution random number distribution produces random numbers distributed according to the probability density function

template class gamma_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


gamma_distribution() : gamma_distribution(1.0) {}
explicit gamma_distribution(RealType alpha, RealType beta = 1.0);
explicit gamma_distribution(const param_type& parm);
void reset();


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


RealType alpha() const;
RealType beta() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit gamma_distribution(RealType alpha, RealType beta = 1.0);

Remarks: alpha and betacorrespond to the parameters of the distribution.

Returns:The value of the alpha parameter with which the object was constructed.

Returns:The value of the beta parameter with which the object was constructed.

26.6.8.4.4 Class template weibull_­distribution [rand.dist.pois.weibull]

A weibull_­distribution random number distribution produces random numbers distributed according to the probability density function

template class weibull_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


weibull_distribution() : weibull_distribution(1.0) {}
explicit weibull_distribution(RealType a, RealType b = 1.0);
explicit weibull_distribution(const param_type& parm);
void reset();


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


RealType a() const;
RealType b() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit weibull_distribution(RealType a, RealType b = 1.0);

Remarks: a and bcorrespond to the respective parameters of the distribution.

Returns:The value of the a parameter with which the object was constructed.

Returns:The value of the b parameter with which the object was constructed.

26.6.8.4.5 Class template extreme_­value_­distribution [rand.dist.pois.extreme]

An extreme_­value_­distribution random number distribution produces random numbers xdistributed according to the probability density function247

template class extreme_value_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


extreme_value_distribution() : extreme_value_distribution(0.0) {}
explicit extreme_value_distribution(RealType a, RealType b = 1.0);
explicit extreme_value_distribution(const param_type& parm);
void reset();


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


RealType a() const;
RealType b() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit extreme_value_distribution(RealType a, RealType b = 1.0);

Remarks: a and bcorrespond to the respective parameters of the distribution.

Returns:The value of the a parameter with which the object was constructed.

Returns:The value of the b parameter with which the object was constructed.

26.6.8.5 Normal distributions [rand.dist.norm]

26.6.8.5.1 Class template normal_­distribution [rand.dist.norm.normal]

A normal_­distribution random number distribution produces random numbers xdistributed according to the probability density function

The distribution parameters μ and σare also known as this distribution's meanand standard deviation.

template class normal_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


normal_distribution() : normal_distribution(0.0) {}
explicit normal_distribution(RealType mean, RealType stddev = 1.0);
explicit normal_distribution(const param_type& parm);
void reset();


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


RealType mean() const;
RealType stddev() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit normal_distribution(RealType mean, RealType stddev = 1.0);

Remarks: mean and stddevcorrespond to the respective parameters of the distribution.

Returns:The value of the mean parameter with which the object was constructed.

Returns:The value of the stddev parameter with which the object was constructed.

26.6.8.5.2 Class template lognormal_­distribution [rand.dist.norm.lognormal]

A lognormal_­distribution random number distribution produces random numbers distributed according to the probability density function

template class lognormal_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


lognormal_distribution() : lognormal_distribution(0.0) {}
explicit lognormal_distribution(RealType m, RealType s = 1.0);
explicit lognormal_distribution(const param_type& parm);
void reset();


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


RealType m() const;
RealType s() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit lognormal_distribution(RealType m, RealType s = 1.0);

Remarks: m and scorrespond to the respective parameters of the distribution.

Returns:The value of the m parameter with which the object was constructed.

Returns:The value of the s parameter with which the object was constructed.

26.6.8.5.3 Class template chi_­squared_­distribution [rand.dist.norm.chisq]

A chi_­squared_­distribution random number distribution produces random numbers distributed according to the probability density function

template class chi_squared_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


chi_squared_distribution() : chi_squared_distribution(1.0) {}
explicit chi_squared_distribution(RealType n);
explicit chi_squared_distribution(const param_type& parm);
void reset();


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


RealType n() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit chi_squared_distribution(RealType n);

Remarks: n corresponds to the parameter of the distribution.

Returns:The value of the n parameter with which the object was constructed.

26.6.8.5.4 Class template cauchy_­distribution [rand.dist.norm.cauchy]

A cauchy_­distribution random number distribution produces random numbers xdistributed according to the probability density function

template class cauchy_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


cauchy_distribution() : cauchy_distribution(0.0) {}
explicit cauchy_distribution(RealType a, RealType b = 1.0);
explicit cauchy_distribution(const param_type& parm);
void reset();


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


RealType a() const;
RealType b() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit cauchy_distribution(RealType a, RealType b = 1.0);

Remarks: a and bcorrespond to the respective parameters of the distribution.

Returns:The value of the a parameter with which the object was constructed.

Returns:The value of the b parameter with which the object was constructed.

26.6.8.5.5 Class template fisher_­f_­distribution [rand.dist.norm.f]

A fisher_­f_­distribution random number distribution produces random numbers distributed according to the probability density function

template class fisher_f_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


fisher_f_distribution() : fisher_f_distribution(1.0) {}
explicit fisher_f_distribution(RealType m, RealType n = 1.0);
explicit fisher_f_distribution(const param_type& parm);
void reset();


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


RealType m() const;
RealType n() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit fisher_f_distribution(RealType m, RealType n = 1);

Remarks: m and ncorrespond to the respective parameters of the distribution.

Returns:The value of the m parameter with which the object was constructed.

Returns:The value of the n parameter with which the object was constructed.

26.6.8.5.6 Class template student_­t_­distribution [rand.dist.norm.t]

A student_­t_­distribution random number distribution produces random numbers xdistributed according to the probability density function

template class student_t_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


student_t_distribution() : student_t_distribution(1.0) {}
explicit student_t_distribution(RealType n);
explicit student_t_distribution(const param_type& parm);
void reset();


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


RealType n() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

explicit student_t_distribution(RealType n);

Remarks: n corresponds to the parameter of the distribution.

Returns:The value of the n parameter with which the object was constructed.

26.6.8.6 Sampling distributions [rand.dist.samp]

26.6.8.6.1 Class template discrete_­distribution [rand.dist.samp.discrete]

A discrete_­distribution random number distribution produces random integers i, , distributed according to the discrete probability function

Unless specified otherwise, the distribution parameters are calculated as: for , in which the values , commonly known as the weights, shall be non-negative, non-NaN, and non-infinity.

Moreover, the following relation shall hold:.

template class discrete_distribution { public:

using result_type = IntType;
using param_type  = unspecified;


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();


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


vector<double> probabilities() const;
param_type param() const;
void param(const param_type& parm);
result_type min() const;
result_type max() const;

};

Effects:Constructs a discrete_­distribution object with and .

[ Note

:

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 theCpp17InputIterator requirements ([input.iterators]).

If firstW == lastW, let and .

Otherwise, forms a sequence w of length .

Effects:Constructs a discrete_­distribution object with probabilities given by the formula above.

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);

Mandates: is_­invocable_­r_­v<double, UnaryOperation&, double> is true.

Preconditions: If , let , otherwise let .

The relation holds.

Effects:Constructs a discrete_­distribution object with probabilities given by the formula above, using the following values: If , let .

Otherwise, let for .

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 when invoked with argument k for .

26.6.8.6.2 Class template piecewise_­constant_­distribution [rand.dist.samp.pconst]

A piecewise_­constant_­distribution random number distribution produces random numbers x,, uniformly distributed over each subintervalaccording to the probability density function

The distribution parameters , also known as this distribution's interval boundaries, shall satisfy the relation for .

Unless specified otherwise, the remaining n distribution parameters are calculated as:
in which the values , commonly known as the weights, shall be non-negative, non-NaN, and non-infinity.

Moreover, the following relation shall hold:.

template class piecewise_constant_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


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();


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


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;

};

piecewise_constant_distribution();

Effects:Constructs a piecewise_­constant_­distribution object with ,,, and .

template<class InputIteratorB, class InputIteratorW> piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW);

Mandates:Both of

are true.

Preconditions: InputIteratorB and InputIteratorW each meet theCpp17InputIterator requirements ([input.iterators]).

If firstB == lastB or ++firstB == lastB, let ,,, and .

Otherwise, forms a sequence b of length , the length of the sequence w starting from firstW is at least n, and any for are ignored by the distribution.

Effects:Constructs a piecewise_­constant_­distribution object with parameters as specified above.

template<class UnaryOperation> piecewise_constant_distribution(initializer_list<RealType> bl, UnaryOperation fw);

Mandates: is_­invocable_­r_­v<double, UnaryOperation&, double> is true.

Effects:Constructs a piecewise_­constant_­distribution object with parameters taken or calculated from the following values: If , let ,,, and .

Otherwise, let form a sequence , and let for .

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);

Mandates: is_­invocable_­r_­v<double, UnaryOperation&, double> is true.

Preconditions: If , let , otherwise let .

The relation holds.

Effects:Constructs a piecewise_­constant_­distribution object with parameters taken or calculated from the following values: Let for , and for .

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 and whose operator[] member returns when invoked with argument k for .

vector<result_type> densities() const;

Returns:A vector<result_­type> whose size member returns n and whose operator[] member returns when invoked with argument k for .

26.6.8.6.3 Class template piecewise_­linear_­distribution [rand.dist.samp.plinear]

A piecewise_­linear_­distribution random number distribution produces random numbers x,, distributed over each subintervalaccording to the probability density function

The distribution parameters , also known as this distribution's interval boundaries, shall satisfy the relation for .

Unless specified otherwise, the remaining distribution parameters are calculated as for , in which the values , commonly known as the weights at boundaries, shall be non-negative, non-NaN, and non-infinity.

Moreover, the following relation shall hold:

template class piecewise_linear_distribution { public:

using result_type = RealType;
using param_type  = unspecified;


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();


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


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;

};

piecewise_linear_distribution();

Effects:Constructs a piecewise_­linear_­distribution object with ,,, and .

template<class InputIteratorB, class InputIteratorW> piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, InputIteratorW firstW);

Mandates: is_­invocable_­r_­v<double, UnaryOperation&, double> is true.

Preconditions: InputIteratorB and InputIteratorW each meet theCpp17InputIterator requirements ([input.iterators]).

If firstB == lastB or ++firstB == lastB, let ,,, and .

Otherwise, forms a sequence b of length , the length of the sequence w starting from firstW is at least , and any for are ignored by the distribution.

Effects:Constructs a piecewise_­linear_­distribution object with parameters as specified above.

template<class UnaryOperation> piecewise_linear_distribution(initializer_list<RealType> bl, UnaryOperation fw);

Mandates: is_­invocable_­r_­v<double, UnaryOperation&, double> is true.

Effects:Constructs a piecewise_­linear_­distribution object with parameters taken or calculated from the following values: If , let ,,, and .

Otherwise, let form a sequence , and let for .

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);

Mandates: is_­invocable_­r_­v<double, UnaryOperation&, double> is true.

Preconditions: If , let , otherwise let .

The relation holds.

Effects:Constructs a piecewise_­linear_­distribution object with parameters taken or calculated from the following values: Let for , and for .

Complexity:The number of invocations of fw does not exceed .

vector<result_type> intervals() const;

Returns:A vector<result_­type> whose size member returns and whose operator[] member returns when invoked with argument k for .

vector<result_type> densities() const;

Returns:A vector<result_­type> whose size member returns n and whose operator[] member returns when invoked with argument k for .