From: David G. <dav...@gm...> - 2006-08-21 18:55:21
|
I was a bit surprised today to find that numpy.random.rand doesn't take in a tuple as input for the dimensions of the desired array. I am very used to using a tuple for zeros, ones. Also, wouldn't this mean that it would not be possible to add other non-keyword arguments to rand later? -- David Grant http://www.davidgrant.ca |
From: Travis O. <oli...@ee...> - 2006-08-21 19:02:33
|
David Grant wrote: >I was a bit surprised today to find that numpy.random.rand doesn't >take in a tuple as input for the dimensions of the desired array. I am >very used to using a tuple for zeros, ones. Also, wouldn't this mean >that it would not be possible to add other non-keyword arguments to >rand later? > > > numpy.random.rand?? Return an array of the given dimensions which is initialized to random numbers from a uniform distribution in the range [0,1). rand(d0, d1, ..., dn) -> random values Note: This is a convenience function. If you want an interface that takes a tuple as the first argument use numpy.random.random_sample(shape_tuple). |
From: Alan G I. <ai...@am...> - 2006-08-21 19:05:45
|
On Mon, 21 Aug 2006, David Grant apparently wrote:=20 > I was a bit surprised today to find that numpy.random.rand=20 > doesn't take in a tuple as input for the dimensions of the=20 > desired array. I am very used to using a tuple for zeros,=20 > ones. Also, wouldn't this mean that it would not be=20 > possible to add other non-keyword arguments to rand later?=20 You will find a long discussion of this in the archives. Cheers, Alan Isaac PS Thank you for improving the average predictive accuracy=20 of economists. (You'll understand when you read the thread.) |
From: Robert K. <rob...@gm...> - 2006-08-21 19:08:33
|
David Grant wrote: > I was a bit surprised today to find that numpy.random.rand doesn't > take in a tuple as input for the dimensions of the desired array. I am > very used to using a tuple for zeros, ones. Also, wouldn't this mean > that it would not be possible to add other non-keyword arguments to > rand later? Don't use rand(), then. Use random(). rand()'s sole purpose in life is to *not* take a tuple. If you like, you can read the archives on the several (long) discussions on this and why things are the way they are now. We finally achieved something resembling consensus, so please let's not resurrect this argument. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: David G. <dav...@gm...> - 2006-08-21 23:26:16
|
On 8/21/06, Robert Kern <rob...@gm...> wrote: > > David Grant wrote: > > I was a bit surprised today to find that numpy.random.rand doesn't > > take in a tuple as input for the dimensions of the desired array. I am > > very used to using a tuple for zeros, ones. Also, wouldn't this mean > > that it would not be possible to add other non-keyword arguments to > > rand later? > > Don't use rand(), then. Use random(). rand()'s sole purpose in life is to > *not* > take a tuple. If you like, you can read the archives on the several (long) > discussions on this and why things are the way they are now. We finally > achieved > something resembling consensus, so please let's not resurrect this > argument. Thanks everyone. My only question now is why there is random_sample and random. My guess is that one is there for compatibility with older releases and so I'm not bothered by it. -- David Grant http://www.davidgrant.ca |
From: Robert K. <rob...@gm...> - 2006-08-21 23:38:20
|
David Grant wrote: > Thanks everyone. My only question now is why there is random_sample and > random. My guess is that one is there for compatibility with older > releases and so I'm not bothered by it. Yes. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |
From: Bill B. <wb...@gm...> - 2006-08-21 23:48:12
|
If you like, here's a rand function that takes either a sequence or a tuple. I use this for interactive sessions. def rand(*shape): """ Return an array of the given dimensions which is initialized to random numbers from a uniform distribution in the range [0,1). rand(d0, d1, ..., dn) -> random values or rand((d0, d1, ..., dn)) -> random values """ if len(shape) == 0 or not hasattr(shape[0],'__getitem__'): return numpy.random.rand(*shape) else: if len(shape) != 1: raise TypeError('Argument should either be a tuple or an argument list') else: return numpy.random.rand(*shape[0]) On 8/22/06, David Grant <dav...@gm...> wrote: > > > > On 8/21/06, Robert Kern <rob...@gm...> wrote: > > > > David Grant wrote: > > > I was a bit surprised today to find that numpy.random.rand doesn't > > > take in a tuple as input for the dimensions of the desired array. I am > > > very used to using a tuple for zeros, ones. Also, wouldn't this mean > > > that it would not be possible to add other non-keyword arguments to > > > rand later? > > > > Don't use rand(), then. Use random(). rand()'s sole purpose in life is > > to *not* > > take a tuple. If you like, you can read the archives on the several > > (long) > > discussions on this and why things are the way they are now. We finally > > achieved > > something resembling consensus, so please let's not resurrect this > > argument. > > > > Thanks everyone. My only question now is why there is random_sample and > random. My guess is that one is there for compatibility with older releases > and so I'm not bothered by it. > |