[NumPy-Tickets] [NumPy] #1855: Numerical-stable sum (similar to math.fsum)

NumPy Trac numpy-tickets@scipy....
Thu Jun 2 14:00:21 CDT 2011

#1855: Numerical-stable sum (similar to math.fsum)
 Reporter:  ling    |       Owner:  somebody   
     Type:  task    |      Status:  new        
 Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  1.6.0      
 Keywords:          |  
 For some applications, having a numerical-stable sum is critical.  What I
 mean can be well illustrated in the examples below:

 >>> math.fsum([1, 1e-10] * 1000), numpy.sum([1, 1e-10] * 1000)
 (1000.0000001, 1000.0000001000171)
 >>> math.fsum([1, 1e100, 1, -1e100] * 10000), numpy.sum([1, 1e100, 1,
 -1e100] * 10000)
 (20000.0, 0.0)

 Here math.fsum is a numerical stable sum introduced in Python 2.6, which
 uses the Shewchuk algorithm (seems to be described in

 Other complaints about the plain vanilla numpy.sum could be found in a
 recent thread:

 I hope numpy.sum can also implement something similar (e.g., Shewchuk
 algorithm or Kahan summation algorithm or partial sum).  We could add an
 optional argument "stable=True/False" to numpy.sum and let the user
 decides whether they want a more accuracy (but potentially slower)

Ticket URL: <http://projects.scipy.org/numpy/ticket/1855>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list