title: Can I specify a numpy dtype when generating random values?
body: <p>I'm creating a <code>numpy</code> array of random values and adding them to an existing array containing 32-bit floats. I'd like to generate the random values using the same dtype as the target array, so that I don't have to convert the dtypes manually. Currently I do this:</p>
  
  <pre><code>import numpy as np
  
  x = np.zeros((10, 10), dtype='f')
  x += np.random.randn(*x.shape).astype('f')
  </code></pre>
  
  <p>What I'd like to do instead of the last line is something like:</p>
  
  <pre><code>x += np.random.randn(*x.shape, dtype=x.dtype)
  </code></pre>
  
  <p>but <code>randn</code> (and actually none of the <code>numpy.random</code> methods) does not accept a <code>dtype</code> argument.</p>
  
  <p>My specific question is, is it possible to specify a dtype for random numbers when I create them, without having to call <code>astype</code>? (My guess is that the random number generator is 64 bits long, so it doesn't really make sense to do this, but I thought I'd ask if it's possible.)</p>