+ 8
Random and Probabilty
Hello! I have been trying to wrap my head around the discrete_distribution method of random and am having troubles. I want to use it to produce a random value between one and ten with lower numbers having a higher probabilty of being generated. say 1-5 a 75% chance, 5-8 a 20% chance and finally 9-10 a 5% chance. I have gotten some sample code (see below) from the interwebs but am unsure of how to use it to weigh chances. Am I even on the right track? https://code.sololearn.com/cow77z70k5DX/?ref=app
1 Antwort
+ 7
I *think* I understand.
when using discrete_distribution each value in the array of weights represents a number starting from 0.
So;
discrete_distribution<int> dist { 2, 1};
is like saying pick between 0 and 1 where 0 has a 50% higher chance of being returned
Maybe?