[Scipy-tickets] [SciPy] #50: Statistics Review: gmean

SciPy scipy-tickets@scipy....
Thu Feb 1 11:39:16 CST 2007

#50: Statistics Review: gmean
 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 mauger):

 It seems to me that changing the order of the power and product operators
 will also work fine (this is how I have it implemented). I didn't test the
 relative efficiency of the two methods, though. For the two arrays below,
 stats.gmean gives the *wrong* answer for the first case and Inf for the

 In [1]: from scipy import *

 In [2]: arr = arange(0.5,1.,1e-7)

 In [3]: product(power(arr,1./arr.size))
 Out[3]: 0.735758831225

 In [4]: exp(sum(log(arr))/arr.size)
 Out[4]: 0.735758831225

 In [5]: arr = arange(10000.,100000.,1e-3)

 In [6]: product(power(arr,1./arr.size))
 Out[6]: 47513.4563005

 In [7]: exp(sum(log(arr))/arr.size)
 Out[7]: 47513.4563005

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

More information about the Scipy-tickets mailing list