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