Hi,
numpy doesn't seem to have a function for sampling from simple
categorical distributions. The easiest solution I could come up with was
something like
>>> from numpy.random import multinomial
>>> multinomial(1, [.5, .3, .2]).nonzero()[0][0]
1
but this is bound to be inefficient as soon as th
On Sun, Nov 21, 2010 at 11:17 PM, Bruce Sherwood wrote:
> A colleague showed me a program using Numeric with Python 2.5 which
> ran much faster than the same program using numpy with Python 2.7. I
> distilled this down to a simple test case, characterized by a "for"
> loop in which he does an ele
A colleague showed me a program using Numeric with Python 2.5 which
ran much faster than the same program using numpy with Python 2.7. I
distilled this down to a simple test case, characterized by a "for"
loop in which he does an element-by-element calculation involving
arrays:
from numpy import a
On Sun, Nov 21, 2010 at 5:56 PM, Robert Kern wrote:
> On Sun, Nov 21, 2010 at 19:49, Keith Goodman wrote:
>
>> But this sample gives a difference:
>>
a = np.random.rand(100)
a.var()
>> 0.080232196646619805
var(a)
>> 0.080232196646619791
>>
>> As you know, I'm trying to make a d
On Sun, Nov 21, 2010 at 6:37 PM, Keith Goodman wrote:
> On Sun, Nov 21, 2010 at 3:16 PM, Wes McKinney wrote:
>
>> What would you say to a single package that contains:
>>
>> - NaN-aware NumPy and SciPy functions (nanmean, nanmin, etc.)
>
> I'd say yes.
>
>> - moving window functions (moving_{coun
On Sun, Nov 21, 2010 at 19:49, Keith Goodman wrote:
> But this sample gives a difference:
>
>>> a = np.random.rand(100)
>>> a.var()
> 0.080232196646619805
>>> var(a)
> 0.080232196646619791
>
> As you know, I'm trying to make a drop-in replacement for
> scipy.stats.nanstd. Maybe I'll have to a
On Sun, Nov 21, 2010 at 4:18 PM, wrote:
> On Sun, Nov 21, 2010 at 6:43 PM, Keith Goodman wrote:
>> Does np.std() make two passes through the data?
>>
>> Numpy:
>>
arr = np.random.rand(10)
arr.std()
>> 0.3008736260967052
>>
>> Looks like an algorithm that makes one pass through the da
On Sun, Nov 21, 2010 at 17:43, Keith Goodman wrote:
> Does np.std() make two passes through the data?
Yes. See PyArray_Std() in numpy/core/src/calculation.c
--
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
On Sun, Nov 21, 2010 at 6:43 PM, Keith Goodman wrote:
> Does np.std() make two passes through the data?
>
> Numpy:
>
>>> arr = np.random.rand(10)
>>> arr.std()
> 0.3008736260967052
>
> Looks like an algorithm that makes one pass through the data (one for
> loop) wouldn't match arr.std():
>
>>> n
Does np.std() make two passes through the data?
Numpy:
>> arr = np.random.rand(10)
>> arr.std()
0.3008736260967052
Looks like an algorithm that makes one pass through the data (one for
loop) wouldn't match arr.std():
>> np.sqrt((arr*arr).mean() - arr.mean()**2)
0.30087362609670526
But a
On Sun, Nov 21, 2010 at 3:16 PM, Wes McKinney wrote:
> What would you say to a single package that contains:
>
> - NaN-aware NumPy and SciPy functions (nanmean, nanmin, etc.)
I'd say yes.
> - moving window functions (moving_{count, sum, mean, var, std, etc.})
Yes.
BTW, we both do arr=arr.asty
On Sun, Nov 21, 2010 at 6:02 PM, wrote:
> On Sun, Nov 21, 2010 at 5:09 PM, Keith Goodman wrote:
>> On Sun, Nov 21, 2010 at 12:30 PM, wrote:
>>> On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman wrote:
On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wrote:
> On Sat, Nov 20, 2010 at 7:24
On Sun, Nov 21, 2010 at 5:09 PM, Keith Goodman wrote:
> On Sun, Nov 21, 2010 at 12:30 PM, wrote:
>> On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman wrote:
>>> On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wrote:
On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman wrote:
> On Sat, Nov 20,
On Sun, Nov 21, 2010 at 12:30 PM, wrote:
> On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman wrote:
>> On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wrote:
>>> On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman wrote:
On Sat, Nov 20, 2010 at 3:54 PM, Wes McKinney wrote:
> Keith (and o
Hi,
21/11/10 @ 11:28 (-0800), thus spake John Salvatier:
> yes use the symbol ':'
>
> so you want
>
> t[:,x,y]
I tried that, but it's not the same:
In [307]: t[[0,1],x,y]
Out[307]: array([1, 7])
In [308]: t[:,x,y]
Out[308]:
array([[1, 3],
[5, 7]])
No?
--
Ernest
On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman wrote:
> On Sat, Nov 20, 2010 at 3:54 PM, Wes McKinney wrote:
>
>> Keith (and others),
>>
>> What would you think about creating a library of mostly Cython-based
>> "domain specific functions"? So stuff like rolling statistical
>> moments, nan* funct
2010/11/14 Charles R Harris :
> I keep getting page does not exist.
The comments on the event, https://github.com/blog/744-today-s-outage,
are simply great and stunning.
Friedrich
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.
On Sun, Nov 21, 2010 at 2:48 PM, Keith Goodman wrote:
> On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wrote:
>> On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman wrote:
>>> On Sat, Nov 20, 2010 at 3:54 PM, Wes McKinney wrote:
>>>
Keith (and others),
What would you think about creat
On Sun, Nov 21, 2010 at 10:25 AM, Wes McKinney wrote:
> On Sat, Nov 20, 2010 at 7:24 PM, Keith Goodman wrote:
>> On Sat, Nov 20, 2010 at 3:54 PM, Wes McKinney wrote:
>>
>>> Keith (and others),
>>>
>>> What would you think about creating a library of mostly Cython-based
>>> "domain specific funct
yes use the symbol ':'
so you want
t[:,x,y]
2010/11/21 Ernest Adrogué :
> Hi,
>
> Suppose an array of shape (N,2,2), that is N arrays of
> shape (2,2). I want to select an element (x,y) from each one
> of the subarrays, so I get a 1-dimensional array of length
> N. For instance:
>
> In [228]: t=
read about basic slicing :
http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html
On Sun, Nov 21, 2010 at 11:28 AM, John Salvatier
wrote:
> yes use the symbol ':'
>
> so you want
>
> t[:,x,y]
>
> 2010/11/21 Ernest Adrogué :
>> Hi,
>>
>> Suppose an array of shape (N,2,2), that is N arrays
Hi,
Suppose an array of shape (N,2,2), that is N arrays of
shape (2,2). I want to select an element (x,y) from each one
of the subarrays, so I get a 1-dimensional array of length
N. For instance:
In [228]: t=np.arange(8).reshape(2,2,2)
In [229]: t
Out[229]:
array([[[0, 1],
[2, 3]],
22 matches
Mail list logo