title: Random number from (0,1) in c
body: <p>I want an exponentially distributed variate, and it seems pretty efficient to do:</p>
  
  <pre><code>double exp_variate(double lambda){
      return -log(my_random_function())/lambda;
  }
  </code></pre>
  
  <p>where my_random_function gives a double x, so <code>0 &lt; x &lt; 1</code> (strictly) meaning that I don't ever get <code>-log(0)</code> or <code>0</code>. How would I get a random number that excludes the 0 and 1 values. I'm sure someone would have asked this before, but I can't see it. Also, I'm open to other ways of generating exponentially distributed values.</p>
  
  <p>EDIT: > to &lt;</p>