I really need some help, thank you in advance. The function does work, but doesn't generate random booleans (how I want it to work). If I change the probability to 1, it gives me true, but when I change it to 0.99(or even lower) I always gain 'false' as a result. I thought it could be wrong implemented, and made a double instead of the 0.5 - no change at all. I tried to change the randomization function, but every time I try to use std::bernoulli_distribution (even in other contexts with the default engine function for example), it gives me the same error. Where's the mistake?
Calling the function:
bool success=Random(0.5);
if(success==true){
...}else{...}
Implementation of function:
bool Random(double probability){
std::random_device rd;
std::mt19937 gen(rd());
std::bernoulli_distribution bd(probability);
bool outcome=bd(gen);
return outcome;
}
Aucun commentaire:
Enregistrer un commentaire