[Numpy-discussion] New functions.

Craig Yoshioka craigyk@me....
Wed Jun 1 11:29:50 CDT 2011

yes, and its probably slower to boot.  A quick benchmark on my computer shows that:

a = np.zeros([4000,4000],'f4')+500

takes 0.02 secs

takes 0.1 secs

takes 0.06 secs

so casting the whole array is almost 40% faster than setting the accumulator type!, I would imagine having the type-casting being done on the fly during the mean computation would be even faster. 

On Jun 1, 2011, at 9:11 AM, Bruce Southey wrote:

> On 06/01/2011 11:01 AM, Robert Kern wrote:
>> On Wed, Jun 1, 2011 at 10:44, Craig Yoshioka<craigyk@me.com>  wrote:
>>> would anyone object to fixing the numpy mean and stdv functions, so that they always used a 64-bit value to track sums, or so that they used a running calculation.  That way
>>> np.mean(np.zeros([4000,4000],'f4')+500)
>>> would not equal 511.493408?
>> Yes, I object. You can set the accumulator dtype explicitly if you
>> need it: np.mean(arr, dtype=np.float64)
> Sure but fails to address that the output dtype of mean in this case is 
> np.float64 which one would naively assume is also np.float64:
>>>> np.mean(np.zeros([4000,4000],'f4')+500).dtype
> dtype('float64')
> Thus, we have:
> Tickets 465 and 518
> http://projects.scipy.org/numpy/ticket/465
> http://projects.scipy.org/numpy/ticket/518
> Various threads as well such as:
> http://mail.scipy.org/pipermail/numpy-discussion/2010-December/054253.html
> Bruce
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110601/2d15e269/attachment-0001.html 

More information about the NumPy-Discussion mailing list