title: Generate random integers with probabilities
body: <p>I'm a bit confused about how to generate integer values with probabilities.</p>
  
  <p>As an example, I have four integers with their probability values: 1|0.4, 2|0.3, 3|0.2, 4|0.1</p>
  
  <p>How can I generate these four numbers taking into account their probabilities?</p>