[Scipy-tickets] [SciPy] #47: Statistics Review: nanstd

SciPy scipy-tickets at scipy.net
Sat Dec 30 12:52:08 CST 2006


#47: Statistics Review: nanstd
-------------------------+--------------------------------------------------
 Reporter:  rkern        |        Owner:  rkern                   
     Type:  review       |       Status:  assigned                
 Priority:  normal       |    Milestone:  Statistics Review Months
Component:  scipy.stats  |      Version:  devel                   
 Severity:  normal       |   Resolution:                          
 Keywords:               |  
-------------------------+--------------------------------------------------
Comment (by user_0901):

 This function is completely broken. A quick rewrite yields:

 {{{
 def nanstd(x, axis=0, bias=False):
     """Compute the standard deviation over the given axis ignoring nans
     """
     x, axis = _chk_asarray(x,axis)
     x = x.copy()
     Norig = x.shape[axis]
     Nnan = np.sum(np.isnan(x),axis)*1.0
     n = Norig - Nnan

     x[np.isnan(x)] = 0
     m1 = np.sum(x,axis)/n
     m2 = np.sum((x-m1)**2.0,axis)-(m1*m1)*Nnan
     if bias:
         m2c = m2/n
     else:
         m2c = m2/(n-1.0)
     return np.sqrt(m2c)
 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/scipy/ticket/47#comment:2>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list