Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change a distribution parameters?

Tags:

c++

random

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 ?    
like image 717
vlad4378 Avatar asked Jul 12 '15 20:07

vlad4378


People also ask

What does parameter of distribution mean?

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.

What is the role of parameters in a distribution?

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.

How many parameters does a distribution have?

4 Parameters: The four parameters determine the average, standard deviation, skewness and kurtosis of the distribution.

What are the parameters of a probability 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.


2 Answers

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

like image 144
dreamzor Avatar answered Sep 25 '22 09:09

dreamzor


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);
like image 37
yizzlez Avatar answered Sep 24 '22 09:09

yizzlez