title: How does the Graphite summarize function with avg work?
body: <p>I'm trying to figure out how the Graphite <a href="https://graphite.readthedocs.io/en/latest/functions.html#graphite.render.functions.summarize" rel="nofollow noreferrer">summarize</a> function works. I've the following data points, where X-axis represents time, and Y-axis duration in ms.</p>
  
  <pre><code>+-------+------+
  |   X   |  Y   |
  +-------+------+
  | 10:20 |    0 |
  | 10:30 | 1585 |
  | 10:40 |  356 |
  | 10:50 |    0 |
  +-------+------+
  </code></pre>
  
  <p>When I pick any time window on Grafana more than or equal to 2 hours (why?), and apply <code>summarize('1h', avg, false)</code>, I get a triangle starting at (9:00, 0) and ending at (11:00, 0), with the peak at (10:00, 324).</p>
  
  <p>A formula that a colleague came up with to explain the above observation is as follows.</p>
  
  <p>Let:
  a = Number of data points for a peak, in this case 4.
  b = Number of non-zero data points, in this case 2.</p>
  
  <p>Then <code>avg = sum / (a + b)</code>. It produces <code>(1585+356) / 6 = 324</code> but doesn't match with the definition of any mean I know of. What is the math behind this?</p>