title: Is there any way to find arithmetic mean "better" than sum()/N?
body: <p>Suppose we have N numbers(integers, floats, whatever you want) and want to find their arithmetic mean. Simplest method is to sum all values and divide by number of values:</p>
  
  <pre><code>def simple_mean(array[N]): # pseudocode
      sum = 0
      for i = 1 to N
         sum += array[i]
      return sum / N
  </code></pre>
  
  <p>It works fine, but requires big integers.
  If we don't want big integers and we are fine with rounding errors, and N is the power of two, we can use 'divide-and-conquer' :  <code>((a+b)/2 + (c+d)/2)/2 = (a+b+c+d)/4</code>,  <code>((a+b+c+d)/4 + (e+f+g+h)/4)/2 = (a+b+c+d+e+f+g+h)/8</code>, so on.</p>
  
  <pre><code>def bisection_average(array[N]):
     if N == 1: return array[1]
     return (bisection_average(array[:N/2])+bisection_average(array[N/2:]))/2
  </code></pre>
  
  <p>Any other ways? </p>
  
  <p>PS. <a href="http://codepad.org/wCRCbeFl" rel="noreferrer">playground for lazy</a></p>