title: How to get random number with each number has its own probability
body: <p>For example, I want to get random number from set S = {0, 1, 2, 3}. But instead of each number has same probability to shown (which is 25%), now I have different probability for each number, let say {50%, 30%, 20%, 10%}. 
  How do I code this? In Java or C# (I prefer C#).</p>