title: Random word pick based on the number of times that they were used
body: <p>I have a vector of strings like this one:</p>
  <pre><code>std::vector&lt;string&gt; words ={&quot;word1&quot;, &quot;word2&quot;, &quot;word3&quot;, &quot;word4&quot;}; //and many more
  </code></pre>
  <p>The <code>code</code> randomise the vector ( in an auxiliary vector) and takes the first word from the auxiliary vector. To do this I use <code>random_shuffle</code>. So far, everything goes very well. But now, I would like to minimise repeated words. My idea is to save the number of times a word is used to in another vector of <code>&lt;int&gt;</code> and randomise the words based on some weights that depends on the number of times that a word is selected by the generator. The words used more times have a lower weight and, for instance, the words never used have maximum weight (<code>1.0</code> maybe). Is there something in <code>STL</code> that can do that? If not, does someone can help me on this hard task?
  The task is:</p>
  <ul>
  <li>At beginning all words have the same probability (same weight) of being picked and the random function picks any word with equal weight;</li>
  <li>After first  pick, one of the words will have lower probability because it was already picked once, so,the random function will pick a random word from the list, but the one already picked will have lower probability of being picked;</li>
  <li>After some tries suppose that <code>word1</code> was picked <code>4</code> times <code>word2</code> <code>3</code> times <code>word3</code> <code>3</code> times and <code>word4</code> <code>0</code> times. The word with lower weight is <code>word1</code> and the word maximum weight will be <code>word4</code>. Based on the number of times that word was picked the random function will generate the weights and pick a word.</li>
  </ul>
  <p>thanks in advance</p>