argument handling by uniform

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? Thanks, Alan Isaac

On Fr, 2015-03-13 at 11:57 -0400, Alan G Isaac 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?
I think all of random broadcasts all of these arguments. So if you give two bounds, then you get one of each, could even do a grid of parameter combinations. - Sebastian
Thanks, Alan Isaac
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

On Fri, Mar 13, 2015 at 3:57 PM, Alan G Isaac <alan.isaac@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

On 3/13/2015 12:01 PM, Robert Kern wrote:
Roughly equivalent to:
uni = np.array([ np.random.uniform(-0.5, 201), np.random.uniform(0.5, 201), ])
OK, broadcasting of `low` and `high` is reasonably fun. But is it documented? I was looking at the docstring, which matches the online help: http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.uniform.htm... Thanks, Alan Isaac

`low` and `high` can be arrays so, you received 1 draw from (-0.5, 201) and 1 draw from (0.5, 201). Eric On Fri, Mar 13, 2015 at 11:57 AM, Alan G Isaac <alan.isaac@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?
Thanks, Alan Isaac
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (4)
-
Alan G Isaac
-
Eric Moore
-
Robert Kern
-
Sebastian Berg