title: Random number but with a bias
body: <p>How would I go about creating a random number generator which has a bias to be within a range of numbers?
  say I have this:</p>
  
  <pre><code>$rnum = rand(0,200);
  </code></pre>
  
  <p>so <code>$rnum == 3</code> and next time <code>$rnum == 106</code> then <code>$rnum == 10</code> and so on...</p>
  
  <p>But I would rather have a bias range of say 80 - 120 so it would more likely select a number within the bias range than outside of it. </p>
  
  <p><code>$rnum == 86</code> and next time <code>$rnum == 112</code> then <code>$rnum == 93</code> but still be able to <code>$rnum == 24</code> and so on...</p>
  
  <p>I thought I might have been able to do this:</p>
  
  <pre><code>if($rnum &lt; $middle_of_bias){
      $rnum++;
  }else{
      $rnum--;
  }
  </code></pre>
  
  <p>but didn't really work, as you can see if <code>$rnum == 1</code> after applying the bias it would only make it <code>2</code> not making this method very successful.</p>
  
  <p>Thanks for your help.</p>
  
  <p><strong>Edit: everyones answers were great. I really liked <em>gnur's</em> one and <em>Phil H's</em> I have made my modifications to <em>rmflow's</em> one and it is working how I wanted it to.</strong> <em>Thanks to every one that helped!</em></p>
  
  <pre><code>if (rand(0, 10) &gt; 2)
  {
      $rnum = rand($low, $high);
  }else{
      $rnum = rand(0, $max);
  }
  </code></pre>