if i wanted to give a set of values each a percentage of being chosen how would i go about that for example if i wanted the program to pick a number from one to ten and wanted it to choose all numbers 10% with the exception of 10 being chosen 11% and 1 being chosen 9% of the time
well lol dont think i am quite there yet thats a little over my head, but thanks for your help. I was hoping i could just assign each value a percentage
#include <iostream>
#include <random>
int main()
{
constint nrolls = 1000000; // number of experiments
std::default_random_engine generator; //↓ We don't want any zeroes
std::discrete_distribution<int> distribution {0, 9,10,10,10,10,
10,10,10,10,11};
//actually you just could add 1 to every random roll, but lets leave it like that for now
int p[11]= {}; //An array holding results of experiment
//Generating random number nrolls times
for (int i=0; i<nrolls; ++i) {
int number = distribution(generator);
++p[number];
}
//Outputting our distribution.
std::cout << "a discrete_distribution:" << std::endl;
for (int i=0; i<11; ++i)
std::cout << i << ": " << (double)p[i]/nrolls*100 << "%"<< std::endl;
return 0;
}