title: How to efficiently compute average on the fly (moving average)?
body: <p>I come up with this</p>
  
  <pre><code>n=1;
  curAvg = 0;
  loop{
    curAvg = curAvg + (newNum - curAvg)/n;
    n++;
  }
  </code></pre>
  
  <p>I think highlights of this way are:<br>
  - It avoids big numbers (and possible overflow if you would sum and then divide)<br>
  - you save one register (not need to store sum)</p>
  
  <p>The trouble might be with summing error - but I assume that generally there shall be balanced numbers of round up and round down so the error shall not sum up dramatically.</p>
  
  <p>Do you see any pitfalls in this solution?
  Have you any better proposal?</p>