Suppose I have a vector<Point> p
of some objects.
I can pick a uniformly random by simply p[rand() % p.size()]
.
Now suppose I have another same-sized vector of doubles vector <double> chances
.
I want to randomly sample from p with each element having a probability analogous to its value in chances
(which may not be summing to 1.0). How can I achieve that in C++?