I want to updtade the parameters (mu,sigma) of lognormal random generator from c++ standard library in my code.
#include <random>
int main()
{
double mu = 1.0;
double sigma = 0.1;
unsigned seed=(int)( time(NULL) );
std::default_random_engine generator (seed);
std::lognormal_distribution<double> LN_dist(mu,sigma)
double h = LN_dist(generator);
cout << h << endl;
The first part is working well. Now I want to update the mu and sigma in the same function (LN_dist) to generate a new random number:
mu = 10.0;
sigma = 0.2;
std::lognormal_distribution<double> LN_dist(mu,sigma)
h = LN_dist(generator);
cout << h << endl;
}
but it make an error for redeclaration of LN_dist function. If I do not declare it, the output will be with the initial mu and sigma in the first part. Also I can't define a new function, because I have to do it more than 100 times. Would you please tell me how can I solve this problem?
Aucun commentaire:
Enregistrer un commentaire