title: Drawing pseudorandoms from a truncated normal distribution
body: <p>Matlab has the function randn to draw from a normal distribution e.g.</p>
  
  <pre><code>x = 0.5 + 0.1*randn() 
  </code></pre>
  
  <p>draws a pseudorandom number from a normal distribution of mean 0.5 and standard deviation 0.1.</p>
  
  <p>Given this, is the following Matlab code equivalent to sampling from a normal distribution truncated at 0 at 1?</p>
  
  <pre><code>    while x &lt;=0 || x &gt; 1
  
      x = 0.5 + 0.1*randn();
  
      end
  </code></pre>