title: Function returning random double with exponential distribution in range (a,b)
body: <p>I want to generate a random number from <code>a</code> to <code>b</code>. The problem is, the number has to be given with exponential distribution. </p>
  
  <p>Here's my code: </p>
  
  <pre><code>public double getDouble(double low, double high)
          {
              double r;
              (..some stuff..)
              r = rand.NextDouble();
              if (r == 0) r += 0.00001;
              return (1 / -0.9) * Math.Log(1 - r) * (high - low) + low;
          }
  </code></pre>
  
  <p>The problem is that (1 / -0.9) * Math.Log(1 - r) is not between 0 and 1, so the result won't be between <code>a</code> and <code>b</code>. Can someone help? Thanks in advance!</p>