[Numpy-discussion] argument handling by uniform

Robert Kern robert.kern at gmail.com
Fri Mar 13 12:01:33 EDT 2015


On Fri, Mar 13, 2015 at 3:57 PM, Alan G Isaac <alan.isaac at gmail.com> wrote:
>
> Today I accidentally wrote `uni = np.random.uniform((-0.5,0.5),201)`,
> supply a tuple instead of separate low and high values.  This gave
> me two draws (from [0..201] I think).  My question: how were the
> arguments interpreted?

Broadcast against each other. Roughly equivalent to:

uni = np.array([
  np.random.uniform(-0.5, 201),
  np.random.uniform(0.5, 201),
])

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150313/ff569f9a/attachment.html>


More information about the NumPy-Discussion mailing list