### percentage of values

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
Last edited on
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
oh wow this just clicked for me thank you
What can you do:
 ``1234567891011121314151617181920212223242526`` ``````#include #include int main() { const int nrolls = 1000000; // number of experiments std::default_random_engine generator; //↓ We don't want any zeroes std::discrete_distribution 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

Output:
 ```a discrete_distribution: 0: 0% 1: 8.98% 2: 9.9638% 3: 9.995% 4: 9.9555% 5: 10.0493% 6: 10.0212% 7: 10.0052% 8: 10.0389% 9: 9.9725% 10: 11.0186%```
Last edited on
Topic archived. No new replies allowed.