title: Lua: How do I calculate a random number between 50 and 500, with an average result of 100?
body: <p>I think this is a log-normal distribution? I'm not sure. The lua I have is here:</p>
  <pre><code>local min = 50
  local max = 500
  local avg = 100
  local fFloat = ( RandomInt( 0, avg ) / 100 ) ^ 2 -- float between 0 and 1, squared
  local iRange = max - min -- range of min-max
  local fDistribution = ( ( fFloat * iRange ) + min ) / 100
  finalRandPerc = fDistribution * RandomInt( min, max ) / 100
  </code></pre>
  <p>It is close to working, but sometimes generates numbers that are slightly too large.</p>