title: Calculating value based on weighted percentage chance
body: <p>I am writing a program in which I need to get a random value based on weighted chances and am having real difficulty.  An example of what I need to do:</p>
  
  <p>a = 50%, b = 30%, c = 10%, d = 10%</p>
  
  <p>In this example, I need to be able to get a random value, a,b,c or d, with the value coming back being as 'a' 50% of the time, b 30% of the time, etc...</p>
  
  <p>Many thanks</p>