There is uniform_int_distribution in < random > When I creating that I define an interval. Can I change this interval after the creation?
for example
std::uniform_int_distribution distr(0, 10);
// can I change an interval here ?
A parameter of a distribution is a number or a vector of numbers describing some characteristic of that distribution. Examples of scalar parameters. Examples of vector parameters.
The parameter values determine the location and shape of the curve on the plot of distribution, and each unique combination of parameter values produces a unique distribution curve. For example, a normal distribution is defined by two parameters, the mean and standard deviation.
4 Parameters: The four parameters determine the average, standard deviation, skewness and kurtosis of the distribution.
It has two parameters—the mean and the standard deviation. The Weibull distribution and the lognormal distribution are examples of other common continuous probability distributions. Both of these distributions can fit skewed data. Distribution parameters are values that apply to entire populations.
Just assign a new distribution to the variable:
std::uniform_int_distribution<int> distr(0, 10);
distr = std::uniform_int_distribution<int>(5, 13);
Or, create a parameter for that (@awesomeyi answer required distribution object creation, this still requires param_type object creation)
std::uniform_int_distribution<int> distr(0, 10);
distr.param(std::uniform_int_distribution<int>::param_type(5, 13));
Proof that param_type will work (for @stefan):
P is the associated param_type. It shall satisfy the CopyConstructible, CopyAssignable, and EqualityComparable requirements. It also has constructors that take the same arguments of the same types as the constructors of D and has member functions identical to the parameter-returning getters of D
http://en.cppreference.com/w/cpp/concept/RandomNumberDistribution
You can through the param()
function.
std::uniform_int_distribution<int> distr(0, 10);
std::uniform_int_distribution<int>::param_type d2(2, 10);
distr.param(d2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With